I've got some Tk Entry objects like:
my($frame_Limit) = $root->Frame ( -relief => 'raised', -borderwidth => '3', ); my($label_Limit) = $root->Label ( -font => '-*-MS Sans Serif-Bold-R-Normal-*-*-120-*-*-*-*-*-*', -relief => 'flat', -text => 'Operand Limit', ); my($entry_Limit) = $root->Entry ( -justify => 'left', -textvariable => \$Limit, -validate => 'focusout', -validatecommand => \&Validate_Number, );
There are several entries like the code above,
My Validation routines are:
# # is_a_positive_integer # # Validate Numbers # # Arguments: $Number # # Returns: $Number or undef on Failure # sub is_a_positive_integer ($) { my $Number = shift; if(!Data::Validate::is_integer($Number)) { return undef; } elsif(!Data::Validate::is_greater_than($Number, 0)) { return undef; } else { return $Number; } } # # Validate_Number # # Tk validateCommand Callback # # Arguments: $NewValue, $CharChange, $CurrentValue, $Index, $ActionTyp +e # # Returns: 0 on Failure to Validate 1 Otherwise # sub Validate_Number ($$$$$) { my $NewValue = shift; my $CharChange = shift; my $CurrentValue = shift; my $Index = shift; my $ActionType = shift; if(defined(is_a_positive_integer($NewValue))) { return(1); } else { return(0); } }
is_a_positive_integer was written for an earlier console version. Validate_Number is a wrapper for it for use by the Tk -validateCommand callback. This all runs fine under "use strict & use warnings.

The problem is that I need to know which entry is making the call so I can take appropriate action. Tk doesn't provide any calling routine information just values.

Any thoughts?

In reply to Tk validateCommand Help by NateTut

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.