1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#!/usr/bin/perl -w
# $Id: preProcess,v 1.3 2013/07/14 22:46:57 tom Exp $
#
# Purpose:
# To demonstrate the preProcess method.
use strict;
#
# Load in the Cdk Extension.
#
use Cdk;
Cdk::init();
# Create a new entry object.
my $title = [ "", "Type in anything but the dreaded letter 'G'!", "" ];
my $entry = new Cdk::Entry(
'Label' => "Type Anything: ",
'Title' => $title,
'Width' => 20,
'Min' => 0,
'Max' => 256
);
# Set up the pre and post processing.
$entry->preProcess( 'Function' => sub { preProcessCB( @_, $entry ); } );
# Activate the object.
my $info = $entry->activate();
# Check the results.
if ( !defined $info ) {
popupLabel( ["<C>You hit escape, nothing returned."] );
}
else {
popupLabel( ["<C>You typed in ($info)"] );
}
# Exit Cdk.
Cdk::end();
#
# This example will set the pre process function so it
# will not accept the letter g.
#
sub preProcessCB {
my ( $input, $entry ) = @_;
# Check the letter.
if ( uc $input eq "G" ) {
Cdk::Beep();
popupLabel( ["<C>I Told You </B>NOT<!B> To Do That"] );
$entry->draw();
return 0;
}
return 1;
}
|