thomthom / SKUI

Ruby wrapper of classes that maps to GUI controls in SketchUp's UI::WebDialogs
MIT License
26 stars 14 forks source link

RadioButton change event fires on off-on transition only #91

Open jimfoltz opened 10 years ago

jimfoltz commented 10 years ago

Not sure if by design, but RadioButton :change event only was getting fired from off-on transition, and not on-off.

thomthom commented 10 years ago

Hmm... that doesn't sound right. Do you have a short sample?

jimfoltz commented 10 years ago
unless defined?(SKUI::Window)
  load 'C:\Users\Jim\Documents\GitHub\@jimfoltz\SKUI\src\SKUI\core.rb'
end

w = SKUI::Window.new

g = SKUI::Groupbox.new('Group Box')
g.right = 5
g.left = 5
g.height = 100
w.add_control( g )

r = SKUI::RadioButton.new( 'Radio' ) { puts 'World! :)' }
r.on(:change) {|ctrl| puts "r changed." }
r.top = 25
r.width = 200
g.add_control( r )

r2 = SKUI::RadioButton.new( 'Radio2' ) { puts 'World! :)' }
r2.on(:change) {|ctrl| puts "r2 changed." }
r2.top = 45 
r2.width = 200
g.add_control( r2 )

b = SKUI::Button.new('Push') {
  p r
  p r.properties
  p r.checked?
  p r2
  p r2.properties
  p r2.checked?
}
b.top = 75

w.add_control( b )
w.show
thomthom commented 10 years ago

Hm...this appear to be by design - not by me - but by the DOM events of the HTML radioboxes... http://stackoverflow.com/a/5176900/486990

Gotta think this one through - you'd think there was a reason why they did it like that. I guess the assumption is that you should be listening to all the radioboxes in the group - when one changes you know the rest also changes. Maybe it's to avoid too many events firing.