in reply to Re^4: Help with JComboBox
in thread Help with JComboBox

Lines 566-569 of my version of JComboBox.pm is
my $mode = $cw->cget('-validate'); if ($mode =~ /match/) { $cw->configure(-validate => 'none'); }
$mode must be undefined and as a result, issues that warning.

The code can be re-written to check before it tries to regex. You can change the code in the module to something like:
my $mode = $cw->cget('-validate'); if (defined $mode && $mode =~ /match/) { # <== change $cw->configure(-validate => 'none'); }
And that will fix the warning. If you are using -validate make sure you aren't pointing to an undef value. All the code does is set -validate to 'none' if it is set to 'match'. It is in the SetSelectedIndex subroutine.

JamesNC

Replies are listed 'Best First'.
Re^6: Help with JComboBox
by rcseege (Pilgrim) on Feb 16, 2005 at 10:52 UTC

    Yes, this is one way of going about fixing it - I have also suggested doing something like:

    my $mode = $cw->cget('-validate') || "none";

    To ensure that there was a value. The thing is it should never have been left to default to undef like it had. I think my preferred fix would be to set a default from the very start ... say at line 207:

    -validate => [qw/METHOD validate Validate none/],

    It's worth mentioning that the newer versions of JComboBox don't have this problem. The newer version also has features that look like they would have helped folks who have posted here before.

    This is probably the first time I've ever checked perlmonks for problems encountered with JComboBox -- I find it a little odd that the questions weren't posted to comp.lang.perl.tk, but I'm glad that folks were able to get help with it, or find better solutions.

    Rob
      Hi Rob,

      I am using "0.02" version of JCombobox.pm. Which is the latest version - right?

      Ton

        No - 1.02 is the latest version on CPAN. You might browse the documentation on CPAN, to see if it's worth your time to upgrade. There's even a section in the docs that mentions alternatives to JComboBox.

Re^6: Help with JComboBox
by TonyDonker (Novice) on Feb 15, 2005 at 07:57 UTC
    Thanks JamesNC - that works! The message is not being generated anymore...!