Open JayTeeSF opened 12 years ago
This is certainly strange behavior.
Can anyone else confirm on other platforms?
if you change the radio groups to symbols (from the manual)
radio_one = radio :group; para "one" radio_two = radio :group; para "two"
it works as expected. You version didn't put them in the same group.
nope; strings and symbols behave the same way (at least on my mbp running osx 10.6.8)
Hmm. I'm using Linux and modified your example slightly:
Shoes.app do radio_one = radio :group; para "one" radio_two = radio :group; para "two"
radio_one.checked = true button "quit" do alert(radio_one.checked? ? "ok" : "failed") # fails exit end end
When I run shoes on ccoupe.rb it still fails initialize radio_one.
↪ cat ccoupe.rb Shoes.app do radio_one = radio :group; para "one" radio_two = radio :group; para "two"
radio_one.checked = true button "quit" do alert(radio_one.checked? ? "ok" : "failed") # fails exit end end
We have a difference between Linux (correct) and OSX (apparently incorrect) and it seems to be the radio_one.checked = that fails on OSX. In ruby.c the function is 'shoes_check_set_checked_m'. On Gtk systems the code in the #ifdef is executed. For Windows and OSX it call 'shoes_check_set_check' (without the trail '-m') which will get you to cocoa.m and that as far as I can help.
thanks! ...I guess the next-step is to contrast that code with the code-path that executes when radio_one.checked= gets called from within the timer-block
Minor correction to my code reading. Linux/GTK manages it's radio grouped buttons. Windows and OSX have to "fake it" by running through the list of radio buttons in the group. That could explain why Jay's code needed the :symbol method on Linux instead of a string parameter. It's not timer that make things work, per se. I suspect that there have been changes in OSX widget handling timing by Apple OS upgrades. The Shoes method of radio and groups creation is not the typical Apple method (as I remember it from old). The group and the button is added w/o text until the para call which has to involve some deferred processing or callback.
Comparing native/gtk.c function 'shoes_native_radio' with the same function in cocoa.m and windows.c suggests that the group arg appears to me to be unused in OSX and Windows. That would be a serious bug.
Confirmed the problem on XP (SP2) and the misbehavior is interesting.
Revised test: Shoes.app do radio_one = radio :group; para "one" radio_two = radio :group; para "two" radio_one.checked = true button "verify" do alert(radio_one.checked? ? "ok" : "failed") # fails end end
When that script runs in XP, NO Buttons are visually selected. That's another bug for XP. When one button is pushed then the group visually sort of acts normally. Looks like _why never finished the Windows and OSX code for radios.
Hi JayTeeSF and folks,
I confirmed the issue on my Windows 7 with Shoes 3.
Try out the following. I think it may be an alternative solution.
Shoes.app do radio_one = radio("group", checked: true); para "one" radio_two = radio("group"); para "two" start do alert(radio_one.checked? ? "ok" : "failed") end end
ashbb
Nice; I switched from using a timer to a start block (in my original code) and it works. It's a much nicer work-around (IMO).
Yep, and this shouldn't be too terrible to fix, either.
Caveat: I've only been using Shoes for a few hours. But after a quick scan of the docs & source code I think this is a bug.
FYI: I'm using shoes policeman (0.r1739) [universal.x86_64-darwin11.1.0 Ruby1.9.1] ...on mac osx 10.6.8
The following fails: Shoes.app do radio_one = radio("group"); para "one" radio_two = radio("group"); para "two"
initialize the button(s):
radio_two.checked = false # just to be sure radio_one.checked = true
alert(radio_one.checked? ? "ok" : "failed") # fails end
By adding a button and manually clicking-it I got the radio button to update:
.... button = button("initialize radio buttons") do radio_one.checked = true alert(radio_one.checked? ? "ok" : "failed") # works end ....
So my current work-around is to use a timer:
.... timer(1) do radio_one.checked = true info(radio_one.checked? ? "ok" : "failed") # works end ....