On Fri, Feb 21, 2014 at 8:00 AM, Donald Allen <donaldcal...@gmail.com>wrote:

>
>
>
> On Thu, Feb 20, 2014 at 2:55 PM, Daniel Wagner <dan...@wagner-home.com>wrote:
>
>> Man, you have *got* to get into the habit of creating a minimal working
>> example. =)
>>
>
> Yeah, I know. I only had a 45 year career in computer science, running
> software projects large and small (including the Tenex project at BBN when
> Tenex was the predominant host OS on the ArpaNet), wrote my first computer
> program in 1960 (IBM 1620 assembly code), so I'm still a newbie, still
> learning, but I'm trying.
>
> Seriously, I did attempt to reproduce the problem with a small example and
> got the same result you did -- the popup menu works correctly (our examples
> were almost identical, but I did try yours to be sure and it works
> correctly as it did for you). I have not been able to devote time to this
> since I sent my message, but returned to it yesterday, trying to find the
> difference between what my application is doing and both our small
> examples. This resulted in a useful bit of information: my application has
> another window, call it Window B, that also needs a popup, which I hadn't
> gotten to. I adapted the little snippet of code from the failing window
> (Window A) to produce a right-button popup in Window B. This one works
> correctly.
>
> Window A: a window containing a scrolled window containing a treeview. The
> treeview's model is a TreeModelSort whose child model is a ListStore. The
> popup fails in this window as described.
> Window B: a window containing a scrolled window containing a treeview. The
> treeview's model is a TreeStore. The popup works correctly with this window.
>
> So I'm a bit closer to isolating what's going on here, but I'm not there
> yet.
>

More info, from experiments this morning.

The failing windows are account registers (my application is a personal
financial manager). If I attempt to display a popup in a register with a
lot of rows (transactions), I get the incorrect behavior (first time, the
popup remains on the screen for about 10 seconds; subsequent times, it's up
just for a moment). If I do the same thing with an account with few rows, I
usually get correct behavior. But if I have one of each on the screen and
induce the bad behavior in the one with many rows, I will then get the bad
behavior in the one with few rows. This will also induce the bad behavior
in what I described as Window B above (this is the tree of accounts).
Thinking this might be due to the use of the scrolling window and perhaps
the presence/absence of vertical scrollbars, I diked out the scrolling
window in the account registers; just assigned the view directly to the
window. No change in behavior. Didn't matter.

Again, I have working C version of this application that I began developing
in the summer of 2012 and which I've been using to manage my own finances
for about a year. I've become very interested in Haskell and have done a
few smaller applications in the language with very good results. My thought
was to re-implement the finance application in Haskell, because C is so
much more difficult to write and to read. I'm happy with the user-interface
I've implemented in C and I'm attempting to duplicate it in the Haskell
version. I am also satisfied with the architecture of gtk objects that I
chose in the C version and am replicating it in Haskell. So the Haskell
version does not differ much from the C version in terms of the overall
plan. And none of these issues with popups exist in the C version; it works
correctly. So at least given what I know now, this appears to be a gtk2hs
problem. Could be pilot error, too, but I haven't found it yet. I will keep
working on this as time permits and will share what I learn.

>
>> The minimal framework I could put around your code to make it run is
>> included below. It does not have the problem you describe. Does the code
>> below show the bad behavior you describe when you try it? If not, could
>> you please try to cook up the smallest piece of code that *does*
>> reproduce your problem?
>>
>> ~d
>>
>> import Control.Monad.IO.Class
>> import Graphics.UI.Gtk
>>
>> main = do
>>         initGUI
>>         w <- windowNew
>>         b <- buttonNewWithLabel "foo"
>>         on b buttonPressEvent (tryEvent (do button <- eventButton
>>                                             theTime <- eventTime
>>                                             case button of
>>                                                 RightButton -> liftIO
>> (mouseButtonPressed theTime)
>>                                                 _ -> stopEvent))
>>         containerAdd w b
>>         widgetShowAll w
>>         mainGUI
>>
>> mouseButtonPressed :: TimeStamp -> IO ()
>> mouseButtonPressed theTime
>>     = do menu <- menuNew
>>          print "mouseButtonPressed called"
>>          print ("time", theTime)
>>          menuItem <- menuItemNewWithLabel "New transaction (ctrl-n)"
>>          on menuItem menuItemActivated (putStrLn "activated, lol")
>>          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))
>>
>> On 2014-02-18 20:17, Donald Allen wrote:
>>
>> > 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
>> > [1]
>> >
>> > _______________________________________________
>> > Gtk2hs-devel mailing list
>> > Gtk2hs-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel [2]
>>
>>
>>
>> Links:
>> ------
>> [1]
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&amp;iu=/4140/ostg.clktrk<http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk>
>> [2] https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>>
>
>
------------------------------------------------------------------------------
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