#!/usr/bin/perl -w # $Id: bind,v 1.3 2002/07/24 10:04:32 tom Exp $ # # Purpose: # To demonstrate the character binding features of the # Perl5/Cdk extension. # # # Load in the Cdk Extension. # use Cdk; Cdk::init(); # This callback fills the entry field with a filename. sub callback { my $entryObj = shift @_; # Generate a list of files in the current directory. my @files = <*>; my $filelist = new Cdk::Scroll ('Title' => "Pick A File", 'Height' => 10, 'Width' => 20, 'List' => \@files); # Activate the scrolling list. my $itemPicked = $filelist->activate (); undef $filelist; # Set the filename. $entryObj->set ('Min' => 0, 'Max' => 255, 'Value' => $files[$itemPicked]); # Redraw the entry field. $entryObj->draw(); return 1; } # Create a new entry object. my $title = ["", "Type in a filename or", "Press tab to get a list.", ""]; $filename = new Cdk::Entry ('Label' => "Filename: ", 'Title' => $title, 'Width' => 20, 'Min' => 0, 'Max' => 256); # Create a key binding. my @mesg = ("Hi Mike", "How Are You?"); $filename->bind ('Key' => "KEY_TAB", 'Function' => sub {main::callback ($filename);}); # Activate the object. my $file = $filename->activate(); # Check the results. if (! defined $file) { popupLabel (["Escape hit, no filename entered."]); } else { popupLabel (["You typed in the filename ($file)"]); } # Exit Cdk. Cdk::end();