Lyle Johnson
2005-Apr-27 19:40 UTC
[fxruby-users] Re: FXDataTarget used with FXRadioButton
On Apr 27, 2005, at 6:28 PM, JDReed wrote:> I apologize for emailing you directly instead of the list. This > contains most of what I emailed to the list on 4-19. I''ve been pulling > what''s left of my hair out trying to figure this out.No problem. Sorry I overlooked your previous message; I was out of town on business on the 19th and it probably got lost in the shuffle.> I have code in my initialize routine to set all of my radio buttons to > ?1, no choice. On a new entry, everything works fine. > > It?s when I go into a record that already exists that I have a > problem. My application will correctly save and retrieve the radio > button data from my database, MySQ.L When the display comes up, I can > see the radio button is set to the correct value from the database, > and then it slowly goes blank to the no choice (-1).The way that data targets work can sort-of be summarized like this: The only time a widget "pushes" its value back to the data target is when the user physically clicks on the widget. So merely setting the radio button''s state using its checkState accessor method isn''t going to update the data targets'' values. In contrast, the widget is going to update its state from the data target''s value whenever it (the widget) gets a SEL_UPDATE message -- and that happens whenever there''s some idle time in the GUI. Based on this, and the code snippets that you showed, I''m guessing that when you open up an existing database record, you''re setting the radio buttons'' states directly instead of modifying the associated data target. If that''s the case, you want to modify your dbtofields() method so that it''s instead updating the data target values, e.g. def dbtofields sexDataTarget.value = -1 # I think? if @male == "X" sexDataTarget.value = 0 end if @female == "X" sexDataTarget.value = 1 end end ... or something along those lines. ;) Hope this helps (and let me know if it doesn''t), Lyle