I am trying to pop up a menu when the right button is pressed with the
cursor in a particular treeview. I set up the event handler as follows:

-- Handle buttonPressEvent within the view
on view buttonPressEvent (tryEvent (do button <- eventButton
                                       theTime <- eventTime
                                       case button of
                                          RightButton -> liftIO
(mouseButtonPressed theTime accountRegister globals)
                                          _ -> stopEvent))

and

mouseButtonPressed :: TimeStamp -> AccountRegister -> Globals -> IO ()
mouseButtonPressed theTime accountRegister globals
   = do menu <- menuNew
        print "mouseButtonPressed called"
        print ("time", theTime)
        menuItem <- menuItemNewWithLabel "New transaction (ctrl-n)"
        on menuItem menuItemActivated (newTransaction accountRegister
globals)
        menuShellAppend menu menuItem
        menuItem <- menuItemNewWithLabel "Duplicate selected transaction
(ctrl-d)"
        menuShellAppend menu menuItem
        widgetShowAll menu
        print "about to call menuPopup"
        menuPopup menu (Just (RightButton, theTime))

The first time I press the right button, the menu appears for perhaps 10
seconds and then disappears. During that time, I can click 'New
transaction' and the right thing happens. The second time I press the right
button, the menu appears very briefly, less than a second and then
disappears. Subsequent right clicks behave the same. In other words,
useless.

The debugging prints in mouseButtonPressed all appear in response to the
right clicks. The event time advances, as you would expect.

I'm at a complete loss as to what might be causing this and can't continue
with my project if this is not solved. Any suggestions would be appreciated.
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Gtk2hs-devel mailing list
Gtk2hs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to