Re: [Fxruby-users] Strange Behaviour under Win32 with FXRuby
Status: Inactive
Brought to you by:
lyle
From: Stef <st...@ch...> - 2003-12-10 20:45:31
|
Lyle wrote: > When you referred to it as "remarking", I thought for a moment that > you > were referring to the technique in which the bug disappears as soon as > you tell someone else about it ;) > Hah! no, not quite that unlucky, although i do 'fondly' remember the days of C programming and the ever so fun problem of 'it works when i remove my comments' ;) > > One last teeny tiny probably stupid question, which i know > > breaks OO design but, how would i tie a 'connect' onto a > > button from another class ? Can you typecast the connect > > so that it knows its going onto a FXButton in an instance > > variable or is there a 'widget controller' which i can > > query to get an FXButton 'handle' passed to me? > > If I understand what you're asking, I think I would just second Hugh's > recommendation of putting whatever code is necessary in the block to > call the desired method on the other button, e.g. > > button1.connect(SEL_COMMAND) { > button2.doSomething > } > I understand that this is probably the way that is simpliest however I also believe that reductionism is 'good'. It is preferable in my eyes not to have the same code repeated multiple times in different classes, when it should (in my eyes) belong in the 'parent' class. Imagine this example: class Funky < FXDialogBox def initialize accept=FXButton.new(buttons, "&Accept", nil, self, ID_ACCEPT, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y) end end class Mojo < FXMainWindow def initialize @lp_dialog=Funky.new(self) end end now, from inside the Mojo class, how would I go about tying the connect on the accept to a procedure/method or callback ? I know it may sound crazy, but if i can do one line such as '(FXButton)@lp_dialog.accept.connect(SEL_METHOD... etc) surely that has to be better than the 20 or 23 or so lines that I need to do to create my 'Funky' dialog in the other classes ? Thanks for the pointers (no pun intended) though, most helpful and glad to see that there is a 'live community' that I can learn and support. Lack of arrogance also seems to be a 'Fox Community' strongpoint (unlike certain other Toolkits developers :D regards and thanks Stef |