in reply to Re: Tk::Entry validate question
in thread Tk::Entry validate question

I tried my best to explain a problem but seem not to succeed:

 1. There was an analyzis of a problem inside my message, so your explanation just rewords mine
 2. return 0 if $_[0]=~/\D/; is not enough, because I said there should be at least one digit.
 3. I noticed that I'm worried about current validation scheme in general, where validation occures one extra time, and not just once at the end of change. Number validation was just an example.

Best wishes,
I.R.Baboon.

Replies are listed 'Best First'.
Re: Tk::Entry validate question
by Abigail-II (Bishop) on Jun 14, 2002 at 18:47 UTC
    Ah, I see. Well, one thing you could do is to not validate when there's a delete (using $_ [3]). But that would enable people to erase everything (leaving nothing). I guess you could counteract that by validating on focusout as well, and using invalidCommand to put 0 or so back in the widget (or the last legal entry).

    Abigail

      In my case I really need to have that Tk::Entry to be never empty.
      The reason is following.
      I tried to use same text variable for this Tk::Entry and for other widget Tk::Scale to allow for user to either enter number by hand or to drag scale widget and enter value "visually".

      The point is - that works fine! And it seemed to me to be quite elegant solution.
      And validate works okay, but once Entry became empty (even for just a moment, when that extra validation succeedes) then strange things happen: Scale widget explains that it could not have empty value, then someone prints some Tcl_panic message, garbage could appear after some manipulation and after some other GUI manipulations it could even core dump!

      No coredumps and garbage inside Tk::Entry was noticed in my GUI app otherwise.

      So, I'm still trying to find a way to solve this!

      Best wishes,
      I.R.Baboon.