#!/usr/bin/perl -w # $Id: dialog,v 1.3 2002/07/24 10:04:33 tom Exp $ # # Purpose: # To demonstrate the Perl5 Cdk Dialog Widget. # # Initialize Cdk. # use Cdk; Cdk::init(); # Create the dialog buttons. my @buttons = ("Button 0", "Button 1", "Button 2", "Button 3"); # Create the dialog message. my @mesg = ("This should be centered", "This should be on the left.", "This should be on the right."); # Create the dialog object. my $dialog = new Cdk::Dialog ('Message' => \@mesg, 'Buttons' => \@buttons, 'Xpos' => "CENTER", 'Ypos' => "CENTER", 'Highlight' => "A_REVERSE"); # Create a key binding. $dialog->bind ('Key' => '?', 'Function' => sub {main::callback();}); # Activate the object. my $button = $dialog->activate(); # Check the results. if (!defined $button) { popupLabel (["Escape hit. No button selected."]); } else { popupLabel (["You selected button $button"]); } # Exit Cdk. Cdk::end(); # # This is the callback function to the dialog widget. # sub callback { my $label = new Cdk::Label ('Message' => ["This is the", "callback to the", "dialog widget."]); $label->draw(); $label->wait(); return 1; }