#!../../../perl -w

#
# Purpose:
#	To demonstrate the preProcess method.

#
# Load in the Cdk Extension.
#
use Cdk;
Cdk::init();

# Create a new entry object.
my $entry = new Cdk::Entry ('Label' => "Type Anything:",
				'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 ($input eq "g")
   {
      Cdk::Beep();
      popupLabel (["<C>Sorry, this entry field widget",
			"<C>will not accept the letter g"]);
      $entry->draw();
      return 0;
   }
   return 1;
}
