Created
August 31, 2015 14:07
-
-
Save anaselli/2b9a74cd648b5f1e1217 to your computer and use it in GitHub Desktop.
YItem comparison in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require '_yui' | |
factory = Yui::YUI::widget_factory | |
dialog = factory.create_main_dialog | |
vbox = factory.create_vbox dialog | |
mySelMinSize = factory.create_min_size(vbox, 50, 12) | |
mySel = factory.create_selection_box(mySelMinSize, "Selection Box") | |
mySel.set_notify(1); | |
myOK = factory.create_push_button(vbox, "OK") | |
myItem = Yui::YItem.new( "foo" ) | |
mySel.add_item(myItem) | |
myItem2 = Yui::YItem.new( "bar" ) | |
mySel.add_item(myItem2) | |
while 1 do | |
event = dialog.wait_for_event() | |
if event.event_type == Yui::YEvent::CancelEvent then | |
break | |
end | |
if event.widget == myOK then | |
break | |
end | |
if event.widget == mySel then | |
item = mySel.selected_item; | |
if item == myItem then | |
puts "item comparison works and you chose " + item.label | |
elsif item == myItem2 then | |
puts "item comparison works and you chose " + item.label | |
else | |
puts "item comparison does not work" | |
end | |
end | |
end | |
dialog.destroy | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment