Tom Sawyer wrote:
is there a way to use FXRuby without subclassing from an FXObject? every
example i’ve looked at has something like:
MyAppClass < FXMainWindow
is this neccessary?
I’m not sure I understand the question. FXRuby is a class library just
like any other Ruby class library. If you just want to use the built-in
classes you can do so, e.g.
# Create a button
myButton = FXButton.new(...)
but if you need a customized version of some widget, you might also
choose to subclass it, e.g.
class MySpecialButton < FXButton
def initialize(p, buttonText, buttonIcon)
# Initialize base class first
super(p, buttonText, buttonIcon)
end
end
By convention, most FOX (and FXRuby) applications create an
application-specific subclass of FXMainWindow, and this is what you’ll
see in a majority of the FXRuby example programs. But it’s certainly not
necessary to subclass FXMainWindow, especially for simple little GUIs;
see, for example, the “hello.rb” and “hello2.rb” example programs, which
don’t do any subclassing.
FYI - as a proof of concept i’m making GUtopIa plugable so you can tack
on any GUI toolkit you like. i decide to start with Fox using FXRuby,
even though GTK+ might have been easier, but obviosuly, i’ve run into
the above problem. specifically i can’t seem to get targeted messages to
work.
I don’t know what you mean by “I can’t seem to get targeted messages to
work”. For most FOX widgets you can connect the widget’s command message
(SEL_COMMAND) directly to a Ruby code block, e.g.
myButton = FXButton.new(parent, "Click Me!")
myButton.connect(SEL_COMMAND) { puts "Call me Ishmael" }
Hope this helps,
Lyle