From: Lyle Johnson Date: 2003-07-03T03:01:56+09:00 Subject: Re: FXDataTarget not updating my variable Hans Fugal wrote: > I was aware of what you are talking about, and I actually only want it > to happen on SEL_COMMAND (when the user presses enter). In that respect > it is behaving as I expect (the when), but it is not updating @name like > I expected. (the what) > > I wrote a little test to demonstrate what's happening. As the comment > says inline, I expected the datatarget to change the value of the > variable, but it does not. (That's what the Fox docs seem to indicate > should be happening, at least in my mind.) Oh, no, that's not how the Ruby version of FXDataTarget works. For FXRuby, you need to work directly with the data target's value, i.e. setting it: dt.value = "spam" or reading it back: puts "current value is #{dt.value}" You are correct that this is different from the C++ implementation, because in C++ the data target actually stores a C++ reference to the variable of interest. We can't do that in Ruby, since some of the primitive object types (namely, integers and floats) are immutable objects. If this is too restrictive for your application, you might want to check out some work that Joel VanderWerf has done with his FoxTails extension for FXRuby (http://raa.ruby-lang.org/list.rhtml?name=foxtails). It takes advantage of the "observable" module (another of Joel's creations) to allow you to connect GUI components to observable attributes. This is a potentially much more powerful approach and it may offer the kind of solution you're looking for. Hope this helps, Lyle