Hi Lyle, hi list. I''ve got a few problems getting a subclass of FXScrollArea react on SEL_MOTION and SEL_LEFTBUTTONPRESS. In the constructor I wrote FXMAPFUNC(SEL_MOTION, 0, "onMouseMove") FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, "onLeftClick") I also tried self.connect(SEL_MOTION, method(:onMouseMove)) self.connect(SEL_LEFTBUTTONPRESS, method(:onLeftClick)) But when I use this widget those handler functions are never called, even if I call .setFocus on it. Any ideas? Regards, Jannis
Jannis Pohlmann schrieb:> Hi Lyle, hi list. > > I''ve got a few problems getting a subclass of FXScrollArea react on > SEL_MOTION and SEL_LEFTBUTTONPRESS. > > In the constructor I wrote > > FXMAPFUNC(SEL_MOTION, 0, "onMouseMove") > FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, "onLeftClick") > > I also tried > > self.connect(SEL_MOTION, method(:onMouseMove)) > self.connect(SEL_LEFTBUTTONPRESS, method(:onLeftClick)) > > But when I use this widget those handler functions are never called, even > if I call .setFocus on it. > > Any ideas? > > Regards, > Jannis >Hey Lyle, didn''t you see that message? I don''t want to be impatient, but this problem is really important for a project of mine. I browsed the FOX source and FXRuby''s SWIG interfaces and noticed that FXScrollArea doesn''t implement the SEL_MOTION handler as FXCanvas does. Obviously, FXTable (derived from FXScrollArea) is able to react on SEL_MOTION. FXScrollArea is a subclass of FXComposite which itself is a subclass of FXWindow so shouldn''t classes derived from FXScrollArea be able to handle SEL_MOTION? Same with other cursor messages like SEL...BUTTONPRESS, SEL...BUTTONRELEASE or SEL_CLICKED. No ideas? Thanks in advance, Jannis
On May 16, 2005, at 1:02 PM, Jannis Pohlmann wrote:> I''ve got a few problems getting a subclass of FXScrollArea react on > SEL_MOTION and SEL_LEFTBUTTONPRESS. > > In the constructor I wrote > > FXMAPFUNC(SEL_MOTION, 0, "onMouseMove") > FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, "onLeftClick") > > I also tried > > self.connect(SEL_MOTION, method(:onMouseMove)) > self.connect(SEL_LEFTBUTTONPRESS, method(:onLeftClick)) > > But when I use this widget those handler functions are never called, > even > if I call .setFocus on it.Could you send me some sample code that demonstrates the problem? The first approach that you mentioned is the right idea, although there may be some piece missing in the bridge from FOX to FXRuby. The second example definitely wouldn''t work, because FXScrollArea doesn''t forward those messages to its message target, and that''s what connect() is all about: setting up a map the messages that a widget sends to its message target, and some chunk of code to handle that message.
On May 18, 2005, at 3:14 PM, Jannis Pohlmann wrote:> Hey Lyle, didn''t you see that message?Yes. Sorry I didn''t drop everything and respond immediately.> I don''t want to be impatient, but this problem is really important for > a project > of mine. I browsed the FOX source and FXRuby''s SWIG interfaces and > noticed > that FXScrollArea doesn''t implement the SEL_MOTION handler as FXCanvas > does.Correct. If you look at the message map for the FXScrollArea class (which appears near the top of FXScrollArea.cpp in the FOX source code) you''ll see that the FXScrollArea widget isn''t "listening" for SEL_MOTION events from the FOX event loop.> Obviously, FXTable (derived from FXScrollArea) is able to react on > SEL_MOTION.Yes, also correct. If you look at the message map for FXTable (at the top of FXTable.cpp), that widget *is* listening for SEL_MOTION events (and handling them in the FXTable::onMotion member function).> FXScrollArea is a subclass of FXComposite which itself is a subclass of > FXWindow so shouldn''t classes derived from FXScrollArea be able to > handle > SEL_MOTION?FXScrollArea (and any other class derived from FXWindow) is certainly able to receive those messages, but I guess you could say it''s choosing not to. That is, there''s no entry for SEL_MOTION in FXScrollArea''s message map and so it hasn''t requested that those messages be sent to it. Jeroen presumably did this to avoid sending any possibly unneeded messages to that widget, and left it up to subclasses (like FXTable) to register their interest in receiving those events from the event loop.
Lyle Johnson schrieb:> > On May 16, 2005, at 1:02 PM, Jannis Pohlmann wrote: > >> I''ve got a few problems getting a subclass of FXScrollArea react on >> SEL_MOTION and SEL_LEFTBUTTONPRESS. >> >> In the constructor I wrote >> >> FXMAPFUNC(SEL_MOTION, 0, "onMouseMove") >> FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, "onLeftClick") >> >> I also tried >> >> self.connect(SEL_MOTION, method(:onMouseMove)) >> self.connect(SEL_LEFTBUTTONPRESS, method(:onLeftClick)) >> >> But when I use this widget those handler functions are never called, >> even >> if I call .setFocus on it. > > > Could you send me some sample code that demonstrates the problem? The > first approach that you mentioned is the right idea, although there > may be some piece missing in the bridge from FOX to FXRuby. > > The second example definitely wouldn''t work, because FXScrollArea > doesn''t forward those messages to its message target, and that''s what > connect() is all about: setting up a map the messages that a widget > sends to its message target, and some chunk of code to handle that > message. >Alright, I read your mail concerning "defining events in fox 1.2" and I think I got the point about the .connect() method. Thank''s for explaining that! Here''s my code, originally about 300 lines stripped down to what you should need: require "fox12" require "fox12/responder" require "fox12/colors" include Fox class CustomTable < FXScrollArea include Responder ID_SELF, ID_INPUT = enum(FXScrollArea::ID_LAST, 2) def initialize(parent, tgt, sel) super(parent, LAYOUT_FILL_X|LAYOUT_FILL_Y) setTarget(tgt) setSelector(sel) initEvents end def create super end def initEvents FXMAPFUNC(SEL_PAINT, 0, :onPaint) FXMAPFUNC(SEL_KEYPRESS, 0, :onKeyPress) FXMAPFUNC(SEL_COMMAND, ID_INPUT, :onAcceptInput) # That''s the troublemaker FXMAPFUNC(SEL_MOTION, 0, :onMouseMove) FXMAPFUNC(SEL_CONFIGURE, 0, :onConfigure) FXMAPFUNC(SEL_CHANGED, FXWindow::ID_HSCROLLED, :onHorizontalScroll) FXMAPFUNC(SEL_CHANGED, FXWindow::ID_VSCROLLED, :onVerticalScroll) end def onMouseMove(sender, sel, event) puts "#{self.class}::onMouseMove" end end # Construction of an instance of CustomTable shopItems = CustomTable.new(border, nil, 0) Regards, Jannis
On May 19, 2005, at 6:47 AM, Jannis Pohlmann wrote:> Here''s my code, originally about 300 lines stripped down to what you > should need:<snip> Oh, I think I see it. It''s the thing that I forgot to tell you about. ;) Try adding a call to enable() somewhere in there, in the initialize() method is as good a place as any: def initialize(parent, tgt, sel) super(parent, ...) self.target = tgt self.selector = sel initEvents enable # added this... end and see if that does the trick. Lyle
Hey Lyle.> > On May 19, 2005, at 6:47 AM, Jannis Pohlmann wrote: > >> Here''s my code, originally about 300 lines stripped down to what you >> should need: > > > <snip> > > Oh, I think I see it. It''s the thing that I forgot to tell you about. ;) > > Try adding a call to enable() somewhere in there, in the initialize() > method is as good a place as any: > > def initialize(parent, tgt, sel) > super(parent, ...) > self.target = tgt > self.selector = sel > initEvents > enable # added this... > end > > and see if that does the trick. > > LyleIndeed, it did! Thanks a lot, Lyle. - Jannis