Skip to content

Instantly share code, notes, and snippets.

@anaselli
Created August 31, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaselli/2b9a74cd648b5f1e1217 to your computer and use it in GitHub Desktop.
Save anaselli/2b9a74cd648b5f1e1217 to your computer and use it in GitHub Desktop.
YItem comparison in ruby
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