Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling data types 1

Status
Not open for further replies.

japskar

Programmer
Feb 13, 2002
27
0
0
A couple of days ago I found an very helpful topic regarding control of entry-datatypes.

I've been playing around with the possibillities, and encountered the following problem with, for example, realnumbers:

1. when I set the -validate option to "key", I can't enter something like "2e3" as real number (well, I can by first entering 23, and inserting an e in between). So that's not what I want.
2. when I set the -validate option to "focus", I'd like to receive an errormessage in case of wrong input; but how can I trap that event in this case?

e.g:
pack [entry .e -validate focus -vcmd {string is double %P}]

Best regards,
Jasper van Dijk
 
Maybe this can help you:
Code:
pack [entry .e -validate focus -vcmd {myvcmd %P}]

proc myvcmd {value} {
  if {![string is double $value]}   {
    tk_messageBox -message "wrong input: $value"
    return 0
  }   else   {
    return 1
  }
}
ulis


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top