Tk-QuickForm
view release on metacpan or search on metacpan
lib/Tk/QuickForm/CBaseClass.pm view on Meta::CPAN
package Tk::QuickForm::CBaseClass;
=head1 NAME
Tk::QuickForm::CBaseClass - Base class for items in Tk::QuickForm.
=cut
use strict;
use warnings;
use vars qw($VERSION);
$VERSION = '0.07';
use base qw(Tk::Derived Tk::Frame);
Construct Tk::Widget 'CBaseClass';
use Tie::Watch;
use Carp;
=head1 SYNOPSIS
package MyFormItem;
use base qw(Tk::TabedForm::CBaseClass);
Construct Tk::Widget 'MyFormItem';
=head1 DESCRIPTION
Inherits L<Tk::Frame>
Provides a base class for you to inherit. Helps making items for L<Tk::QuickForm>.
You should never create an instance directly like above. This should
be handled by L<Tk::QuickForm>.
=head1 OPTIONS
=over 4
=item Switch: B<-regex>
By default '.*'. Set a regular expression used for validation.
=item Switch: B<-validatecall>
Callback, called after validation with the result as parameter.
=back
=head1 METHODS
=over 4
=cut
sub Populate {
my ($self,$args) = @_;
my $quickform = delete $args->{'-quickform'};
croak "Option '-quickform' not specified" unless defined $quickform;
$self->SUPER::Populate($args);
my $var = '';
Tie::Watch->new(
-variable => \$var,
-store => sub {
my ($watch, $value) = @_;
$watch->Store($value);
$self->Callback('-validatecall');
},
);
$self->{VARIABLE} = \$var;
$self->{QUICKFORM} = $quickform;
$self->createHandler(\$var);
( run in 1.748 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )