From: Lyle Johnson Date: 2001-06-28T23:24:00+09:00 Subject: [ruby-talk:17009] Re: FOX subclassing FXTextField and messages > I want to subclass FXTextField in order to map certain keys, eg Ctrl-Left, > but don't know how to do this. onKeyPress doesn't get called. > > class MyTextField < FXTextField > def onKeyPress(sender, sel, ptr) > p "onKeyPress" > super(sender, sel, ptr) > end > end > > I'm missing something important here but what? Message handlers (like your "onKeyPress" method) need to be registered with FOX so that it knows to call them. class MyTextField < FXTextField def initialize(p, ncols, tgt, sel, opts) # Be sure to call the base class constructor! super(p, ncols, tgt, sel, opts) # Map the SEL_KEYPRESS message to the onKeyPress instance method FXMAPFUNC(SEL_KEYPRESS, 0, "onKeyPress") end def onKeyPress(sender, sel, ptr) ... whatever ... end end For some more information about FOX's message and target system, see: http://www.fox-toolkit.org/messages.html Hope this helps, Lyle