New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radio button, unusual behaviour #117

Closed
ProvGANG opened this Issue Apr 14, 2015 · 9 comments

Comments

Projects
None yet
3 participants
@ProvGANG

ProvGANG commented Apr 14, 2015

I'm not sure if there is something wrong in the way I'm treating radio buttons or this is somewhat unusual behaviour...

Shoes.app do
  @s = stack do
   @r1 = radio :items
   @r2 = radio :items
  end

button "Clear" do
  @s.clear do
    @r1 = radio :items
    @r2 = radio :items
  end
 end
end

What actually happens is that after the stack is cleared and filled with radio buttons again, they all become checked and therefore useless in further usage. From some reasons they do not get assigned to same group when appended to stack.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Apr 15, 2015

Contributor

It's not good behavior - there are gtk-critical error message on the console. If you change the group name in the clear block to say :newitems - it will work - once. I suspect the slot.clear is not deleting the radio group when the last member of the group is removed.

Like you, I question the wisdom of treating radio buttons that way but It does work on OSX so it's probably a bug. BTW - Don't depend on the first radio being checked if you didn't say which one is checked in a group.

Contributor

ccoupe commented Apr 15, 2015

It's not good behavior - there are gtk-critical error message on the console. If you change the group name in the clear block to say :newitems - it will work - once. I suspect the slot.clear is not deleting the radio group when the last member of the group is removed.

Like you, I question the wisdom of treating radio buttons that way but It does work on OSX so it's probably a bug. BTW - Don't depend on the first radio being checked if you didn't say which one is checked in a group.

@ccoupe ccoupe added Low and removed Normal labels Apr 15, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Apr 15, 2015

Contributor

Too quote the manual (which I can't select and copy) - " you can group together radios from different slots, you just have to give them all the same group name." Since the group name is a Ruby :symbol they live for the length of the program. Perhaps you can discover the Ruby incantation to remove a :symbol and put that in your clear block or just invent a new symbol.

Contributor

ccoupe commented Apr 15, 2015

Too quote the manual (which I can't select and copy) - " you can group together radios from different slots, you just have to give them all the same group name." Since the group name is a Ruby :symbol they live for the length of the program. Perhaps you can discover the Ruby incantation to remove a :symbol and put that in your clear block or just invent a new symbol.

@ProvGANG

This comment has been minimized.

Show comment
Hide comment
@ProvGANG

ProvGANG Apr 15, 2015

Alright I've found some kind of solution for this problem. Whenever I clear the block, new symbol is assigned to the group.

Shoes.app do
  @s = stack do
    @r1 = radio :items
    @r2 = radio :items
  end

 $count = 0
 button "Clear" do
  $count += 1
  @symbol = $count.to_s.to_sym
  @s.clear do
    @r1 = radio @symbol
    @r2 = radio @symbol
  end
 end
end

ProvGANG commented Apr 15, 2015

Alright I've found some kind of solution for this problem. Whenever I clear the block, new symbol is assigned to the group.

Shoes.app do
  @s = stack do
    @r1 = radio :items
    @r2 = radio :items
  end

 $count = 0
 button "Clear" do
  $count += 1
  @symbol = $count.to_s.to_sym
  @s.clear do
    @r1 = radio @symbol
    @r2 = radio @symbol
  end
 end
end
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Apr 15, 2015

Contributor

Consider the more common layout - per the manual suggestion

stack do
   flow { @r1 = radio :grupo1; para "Choice 1" }
   flow { @r2 = radio :grupo1: para "Choice 2" }
end

That demonstrates that :grupo1 is not part of a a stack or a flow. It has to be something that doesn't belong to a slot.

Contributor

ccoupe commented Apr 15, 2015

Consider the more common layout - per the manual suggestion

stack do
   flow { @r1 = radio :grupo1; para "Choice 1" }
   flow { @r2 = radio :grupo1: para "Choice 2" }
end

That demonstrates that :grupo1 is not part of a a stack or a flow. It has to be something that doesn't belong to a slot.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Apr 15, 2015

Contributor

Forgot to mention - if you invent lots of new :symbols - they don't get garbage collected in Ruby 2.1.x so you probably don't want to do that a lot.

Contributor

ccoupe commented Apr 15, 2015

Forgot to mention - if you invent lots of new :symbols - they don't get garbage collected in Ruby 2.1.x so you probably don't want to do that a lot.

passenger94 added a commit to passenger94/shoes3 that referenced this issue Apr 15, 2015

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Apr 15, 2015

Contributor

ok made a pull request
looks it works now, canvas->app->groups, group wasn't cleared
.

meanwhile i stumble upon something wrong with checked= ...
not a big deal, if in a group of 2 radios i check one radio with checked= true, i need to set the other one to false (checked = false) to make it work
i was expecting to set only one in the group, and the group feature taking care of the other radios ...
is this feature only intended for the gui and not for coding ?

if @r1.checked?
    @r1.checked = false
    @r2.checked = true
else
    @r1.checked = true
    @r2.checked = false
end
Contributor

passenger94 commented Apr 15, 2015

ok made a pull request
looks it works now, canvas->app->groups, group wasn't cleared
.

meanwhile i stumble upon something wrong with checked= ...
not a big deal, if in a group of 2 radios i check one radio with checked= true, i need to set the other one to false (checked = false) to make it work
i was expecting to set only one in the group, and the group feature taking care of the other radios ...
is this feature only intended for the gui and not for coding ?

if @r1.checked?
    @r1.checked = false
    @r2.checked = true
else
    @r1.checked = true
    @r2.checked = false
end
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Apr 15, 2015

Contributor

checked= is one those things that may have to be called in a start block (or timer).

Contributor

ccoupe commented Apr 15, 2015

checked= is one those things that may have to be called in a start block (or timer).

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Apr 15, 2015

Contributor

and of course, one need to set a radio to be checked ! for the others to be unchecked (@r1.checked = !@r1checked? doesn't make sense ! )

@r1.checked? ? @r2.checked = true : @r1.checked = true

forget it :-D

Contributor

passenger94 commented Apr 15, 2015

and of course, one need to set a radio to be checked ! for the others to be unchecked (@r1.checked = !@r1checked? doesn't make sense ! )

@r1.checked? ? @r2.checked = true : @r1.checked = true

forget it :-D

ccoupe added a commit that referenced this issue Apr 21, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Apr 21, 2015

Contributor

the fix doesn't hurt OSX (which behaved correctly)

Contributor

ccoupe commented Apr 21, 2015

the fix doesn't hurt OSX (which behaved correctly)

@ccoupe ccoupe added this to the 3.2.23 milestone Apr 21, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment