Hi all, Recently I started using FXRuby (on windows) for a prototype visualization package. ''Til everything went nice and smooth. Thanks for a nice toolkit. One of the things I am trying to do is to map different mousebutton combinations to different interactions. To give feedback, I would like to update the cursor to indicate the interaction triggered. My approach was to enable the wait cursor when the mouse button was pressed, and switch wait cursors for different combinations of mouse buttons. To see which combination of mouse buttons is pressed, I use the event.state property. Could you please answer some questions: 1. When I press left & middle inside the canvas, move the mouse outside the fx-window and release both buttons, I get only one callback for the RELEASE, eventhough I keep the canvas grabbed. Is this expected? 2. Is the beginWaitCursor / endWaitCursor / setWaitCursor the right strategy? I''ve been playing around with setting the cursors, but I get quite some crashes. 3. I''ve created a different default cursor, which I assign to the DEF_ARROW_CURSOR. When I assign it to DEF_RARROW_CURSOR too, I get a crash during exiting. Am I doing something wrong? 4. It seems defaultCursor= is an alias to setDefaultCursor. However, this takes two parameters, which is kindof unexpected for a set-property. Did I misunderstand the meaning of defaultCursor= ? Thanks for taking the time to answer my questions. Groeten/Regards, Ronald.
On Thursday 13 July 2006 07:55, Ronald Pijnacker wrote:> Hi all, > > Recently I started using FXRuby (on windows) for a prototype > visualization package. > ''Til everything went nice and smooth. Thanks for a nice toolkit. > > One of the things I am trying to do is to map different mousebutton > combinations to different interactions. To give feedback, I would like > to update the cursor to indicate the interaction triggered. > > My approach was to enable the wait cursor when the mouse button was > pressed, and switch wait cursors for different combinations of mouse > buttons. To see which combination of mouse buttons is pressed, I use the > event.state property. > > Could you please answer some questions: > > 1. When I press left & middle inside the canvas, move the mouse outside > the fx-window and release both buttons, I get only one callback for > the RELEASE, eventhough I keep the canvas grabbed. Is this expected? > > 2. Is the beginWaitCursor / endWaitCursor / setWaitCursor the right > strategy? I''ve been playing around with setting the cursors, but I > get quite some crashes. > > 3. I''ve created a different default cursor, which I assign to the > DEF_ARROW_CURSOR. When I assign it to DEF_RARROW_CURSOR too, I get a > crash during exiting. Am I doing something wrong? > > 4. It seems defaultCursor= is an alias to setDefaultCursor. However, > this takes two parameters, which is kindof unexpected for a > set-property. Did I misunderstand the meaning of defaultCursor= ? > > Thanks for taking the time to answer my questions. > > Groeten/Regards,1) If the first RELEASE causes the widget to ungrab(), the second RELEASE will go to the widget under the cursor. 2) I''d reserve beginWaitCursor()/endWaitCursor() for situations where the GUI is "busy" for a long while, e.g. when reading files. If you just want to change the cursor duing a grab, change the grab cursor using setDragCursor(), and it will be automatically used while the grab is in effect. 3) These are really "stock cursors" and they can be changed only BEFORE creating any widgets; when a widget is created, it gets its cursor from FXApp; you can use this to install your own custom cursor-theme if you need. It affects ALL widgets. Rather than changing FXApp''s cursors, I recommend changing the cursor of a specific widget only, using setDefaultCursor() and setDragCursor(). 4) This is an FXRuby question for Lyle I think; I can only say that in FOX itself there''s only 1 parameter, the cursor... Groeten, Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 23:30 03/30/2006 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+
On Thursday 13 July 2006 08:53, Ronald Pijnacker wrote:> > On Thursday 13 July 2006 07:55, Ronald Pijnacker wrote: > > > Hi all, > > > > > > Recently I started using FXRuby (on windows) for a prototype > > > visualization package. > > > ''Til everything went nice and smooth. Thanks for a nice toolkit. > > > > > > One of the things I am trying to do is to map different mousebutton > > > combinations to different interactions. To give feedback, I would like > > > to update the cursor to indicate the interaction triggered. > > > > > > My approach was to enable the wait cursor when the mouse button was > > > pressed, and switch wait cursors for different combinations of mouse > > > buttons. To see which combination of mouse buttons is pressed, I use the > > > event.state property. > > > > > > Could you please answer some questions: > > > > > > 1. When I press left & middle inside the canvas, move the mouse outside > > > the fx-window and release both buttons, I get only one callback for > > > the RELEASE, eventhough I keep the canvas grabbed. Is this expected? > > > > > > 2. Is the beginWaitCursor / endWaitCursor / setWaitCursor the right > > > strategy? I''ve been playing around with setting the cursors, but I > > > get quite some crashes. > > > > > > 3. I''ve created a different default cursor, which I assign to the > > > DEF_ARROW_CURSOR. When I assign it to DEF_RARROW_CURSOR too, I get a > > > crash during exiting. Am I doing something wrong? > > > > > > 4. It seems defaultCursor= is an alias to setDefaultCursor. However, > > > this takes two parameters, which is kindof unexpected for a > > > set-property. Did I misunderstand the meaning of defaultCursor= ? > > > > > > Thanks for taking the time to answer my questions. > > > > > > Groeten/Regards, > > > > 1) If the first RELEASE causes the widget to ungrab(), the second > > RELEASE will go to the widget under the cursor. > > As stated, I do not ungrab until all mouse buttons are released. It > seems as if the ungrab does happen, though. > > > 2) I''d reserve beginWaitCursor()/endWaitCursor() for situations where > > the GUI is "busy" for a long while, e.g. when reading files. > > If you just want to change the cursor duing a grab, change the > > grab cursor using setDragCursor(), and it will be automatically > > used while the grab is in effect. > > I''ve tried this approach, however setting the default cursor or the drag > cursor on a FXGLCanvas consistently crashes the application.Probably, with the message: "Cursor has not been created yet." It is necessary to explicitly call create() on resources which didn''t yet exist as part of the widget hierarchy at the time that create() was called on FXApp.> > 3) These are really "stock cursors" and they can be changed only BEFORE > > creating any widgets; when a widget is created, it gets its cursor > > from FXApp; you can use this to install your own custom cursor-theme > > if you need. It affects ALL widgets. > > That is what I intend to do: override the defaults for all the widgets. > I do this directly after creating the application and before creating > the main window (or any other widgets). In itself, it works fine, it is > just crashing the program on program exit. That only happens when I set > the same cursor for two different defaults, so my guess would be that > there is a double free/release executed somewhere.That would be my guess, yes. You''d need two instances of the same cursor in the case you want two originally different cursors to display the same glyph.> > Rather than changing FXApp''s cursors, I recommend changing the cursor > > of a specific widget only, using setDefaultCursor() and setDragCursor(). > > > > 4) This is an FXRuby question for Lyle I think; I can only say that in FOX > > itself there''s only 1 parameter, the cursor... > > You are right. I was looking at the setDefaultCursor for FXApp, which > has two parameters. > > Still do not know where all the crashes come from, though. Did you have > much success with setting non-stock cursors?It should work fine; just keep in mind that FXApp thinks it "owns" them and thus will try to manage the lifetime of these resources. They''re normally not changed by applications, unless for the purpose of theming cursor collections, perhaps. Groeten, - Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 23:30 03/30/2006 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+
> > I''ve tried this approach, however setting the default cursor or the drag > > cursor on a FXGLCanvas consistently crashes the application. > > Probably, with the message: > > "Cursor has not been created yet." > > It is necessary to explicitly call create() on resources which didn''t > yet exist as part of the widget hierarchy at the time that create() was > called on FXApp.You''re right on the spot! Great. I did not see that message, though.> > > 3) These are really "stock cursors" and they can be changed only BEFORE > > > creating any widgets; when a widget is created, it gets its cursor > > > from FXApp; you can use this to install your own custom cursor-theme > > > if you need. It affects ALL widgets. > > > > That is what I intend to do: override the defaults for all the widgets. > > I do this directly after creating the application and before creating > > the main window (or any other widgets). In itself, it works fine, it is > > just crashing the program on program exit. That only happens when I set > > the same cursor for two different defaults, so my guess would be that > > there is a double free/release executed somewhere. > > That would be my guess, yes. You''d need two instances of the same cursor > in the case you want two originally different cursors to display the same > glyph.Somehow, FXCursor.dup does not seem to work. Can I copy the cursor somehow (except for the perfectly obvious choice).> > > Rather than changing FXApp''s cursors, I recommend changing the cursor > > > of a specific widget only, using setDefaultCursor() and setDragCursor(). > > > > > > 4) This is an FXRuby question for Lyle I think; I can only say that in FOX > > > itself there''s only 1 parameter, the cursor... > > > > You are right. I was looking at the setDefaultCursor for FXApp, which > > has two parameters. > > > > Still do not know where all the crashes come from, though. Did you have > > much success with setting non-stock cursors? > > It should work fine; just keep in mind that FXApp thinks it "owns" them > and thus will try to manage the lifetime of these resources. They''re > normally not changed by applications, unless for the purpose of theming > cursor collections, perhaps.That is sort-of what I am trying to do. With the .create() in place it works like a charm. Thanks for the tip. The only problem left is that of the missing mouse-up events. But I think I can work around that. Groeten, Ronald