[fxruby-users] Attribute Binding

Berin Loritsch bloritsch at d-haven.org
Fri Feb 11 21:31:27 EST 2005

I am generally new to Ruby and more specifically FXRuby.  I come from a 
Java background, but have been recently looking at SmallTalk and Ruby 
and I wanted to compare and contrast the languages.  I have a library in 
Java that will allow me to bind a class attribute directly to a GUI 
control.  It uses JavaBean technology and the PropertyChangeEvent 
signals that are sent every time the value changes.  SmallTalk provides 
this support as part of the core language.  My question is how do I do 
that with Ruby?

For example, I have a BankAccount class (yes I know its a toy app, but 
it will help me understand what to do) with a "balance" attribute.  The 
BankAccount class works wonderfully by itself.  I have a method to 
deposit and a method to withdraw funds from this BankAccount class.  I 
want to be able to set up a button like this:

FXButton.new(window, "&Deposit").connect(SEL_COMMAND) { @account.deposit 
200 }

And as a result of that action have the FXTextField automatically update 
itself with the new balance.  I don't see a lot of examples of this type 
of thing, and I am not even sure if it is possible (it must be).  Has 
anyone had any luck with this?

More information about the fxruby-users mailing list