Created
August 31, 2015 14:04
-
-
Save anaselli/69a8a7c9f9d3162a9e98 to your computer and use it in GitHub Desktop.
YItem comparison in perl
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
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