Piet Hadermann
2005-Oct-27 23:39 UTC
[fxruby-users] SEL_LEFTBUTTONPRESS cause ''autograb'' ???
Hello list! After the initial troubles getting fxruby up and running, I''m really enjoying both ruby and fxruby. BTW:Lyle: about half of the times I turned to the web/googlegroups/... to find solutions to an issue it was answered in a message/post from you. They should give you a ruby statue or something. Or maybe 2:one for making fxruby, one for being so much help handling problems/questions. Thanks! Most things just work as expected and I''ve been flabbergasted a few times seeing how easy it can be to implement even more advanced gui trickery. The only gui related programming I''ve been doing the last couple of years was with the vc++/mfc combo, and ruby/fxruby is really breath of fresh air that makes you do things instead of wondering how you should do them. However, there''s something weird bugging me at the moment. I''ll use the ''fx_button.rb'' example to explain things. I added the following in ButtonWindow.initialize: @button.connect(SEL_LEFTBUTTONPRESS) { puts ''lmb pressed'' } @button.connect(SEL_LEFTBUTTONRELEASE) { puts ''lmb release'' } If I run this, the SEL_LEFTBUTTONPRESS gets handled, but SEL_LEFTBUTTONRELEASE doesn''t. Also, it seems this causes all events to be automatically ''grabbed'' to ''button'' and I am not able to click any other button. I can''t even close the window (except when using ALT-F4). Everytime I press the left mousebutton, no matter where, it gets handled by that button handler (after pressing the button once). If I add an ''ungrab'' in there, like this: @button.connect(SEL_LEFTBUTTONPRESS) { puts ''lmb pressed'' @button.ungrab } I can at least close the window again and pressing other buttons gets handled again. But, SEL_LEFTBUTTONRELEASE stil doesn''t seem to get handled. If I just delete handling of SEL_LEFTBUTTONPRESS, then SEL_LEFTBUTTONRELEASE gets handled when I release left mousebutton. I get the same behaviour under a WinXP as wel as a Fedore Core 3 installation, both using fxruby 1.4.2. (ah yes: basically this is a first step in wanting to click that button and move it around) Is this a bug or am I seeing/assuming things wrong ? Thanks in Advance! Piet.
Lyle Johnson
2005-Oct-28 00:20 UTC
[fxruby-users] SEL_LEFTBUTTONPRESS cause ''autograb'' ???
On Oct 27, 2005, at 6:39 PM, Piet Hadermann wrote:> However, there''s something weird bugging me at the moment. I''ll use the > ''fx_button.rb'' example to explain things. > > I added the following in ButtonWindow.initialize: > > @button.connect(SEL_LEFTBUTTONPRESS) { > puts ''lmb pressed'' > } > > @button.connect(SEL_LEFTBUTTONRELEASE) { > puts ''lmb release'' > } > > If I run this, the SEL_LEFTBUTTONPRESS gets handled, but > SEL_LEFTBUTTONRELEASE doesn''t. Also, it seems this causes all events to > be automatically ''grabbed'' to ''button'' and I am not able to click any > other button.OK, I''m seeing this too and as far as I can tell it''s a bug. The button is supposed to grab the mouse cursor when the button goes down, and then send the SEL_LEFTBUTTONPRESS message to the target (and this is happening). But when the button goes up, it''s supposed to ungrab and then send you SEL_LEFTBUTTONRELEASE (and this is *not* happening). I''ll try to figure out what''s wrong and get this fixed ASAP.
Lyle Johnson
2005-Oct-29 15:11 UTC
[fxruby-users] SEL_LEFTBUTTONPRESS cause ''autograb'' ???
On Oct 27, 2005, at 6:39 PM, Piet Hadermann wrote:> If I run this, the SEL_LEFTBUTTONPRESS gets handled, but > SEL_LEFTBUTTONRELEASE doesn''t...Just a follow-up to my previous response, this apparently is not a bug but a "feature". The standard message handler for SEL_LEFTBUTTONPRESS on an FXButton widget gives the button''s message target the first chance to handle that message. If the button''s message target *does* handle the message (i.e. the message handler returns something other than false), then FXButton considers the message handling complete and doesn''t do any additional processing. This is what''s happening in your case, when you have a handler like so: @button.connect(SEL_LEFTBUTTONPRESS) { puts "pressed" } The problem is that, for your purposes, you *do* want FXButton to do that additional processing after your code has done its handling of SEL_LEFTBUTTONPRESS. For that reason, you need to modify your handler code so that when it''s done, it returns false, e.g.: @button.connect(SEL_LEFTBUTTONPRESS) { puts "pressed" ; false } You''d want to do the same thing in your SEL_LEFTBUTTONRELEASE handler. Hope this helps, Lyle