Skip to content

Instantly share code, notes, and snippets.

@anaselli
Created August 31, 2015 14:04
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/69a8a7c9f9d3162a9e98 to your computer and use it in GitHub Desktop.
Save anaselli/69a8a7c9f9d3162a9e98 to your computer and use it in GitHub Desktop.
YItem comparison in perl
use yui;
my $factory = yui::YUI::widgetFactory;
my $dialog = $factory->createMainDialog;
my $vbox = $factory->createVBox( $dialog );
my $selMinSize = $factory->createMinSize($vbox, 50, 12);
my $sel = $factory->createSelectionBox($selMinSize, "Selection Box");
$sel->setNotify(1);
my $OK = $factory->createPushButton($vbox, "OK");
my $item1 = yui::YItem->new( "foo" );
$sel->addItem($item1);
my $item2 = yui::YItem->new( "bar" );
$sel->addItem($item2);
while (1) {
my $event = $dialog->waitForEvent();
last if $event->eventType() == $yui::YEvent::CancelEvent;
last if $event->widget() == $OK;
if ($event->widget() == $sel) {
my $item = $sel->selectedItem();
if ($item == $item1) {
print "item comparison works and you chose ". $item->label() ." \n";
}
elsif ($item == $item2) {
print "item comparison works and you chose ". $item->label() ." \n";
}
else {
print "item comparison does not work\n";
}
}
}
$dialog->destroy();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment