diff options
Diffstat (limited to 'itcl/iwidgets/demos/entryfield')
-rw-r--r-- | itcl/iwidgets/demos/entryfield | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/itcl/iwidgets/demos/entryfield b/itcl/iwidgets/demos/entryfield new file mode 100644 index 00000000000..da278a8fd80 --- /dev/null +++ b/itcl/iwidgets/demos/entryfield @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------------- +# DEMO: entryfield in [incr Widgets] +# ---------------------------------------------------------------------- +package require Iwidgets 4.0 + +option add *textBackground seashell +. configure -background white + +iwidgets::entryfield .login -labeltext "Login:" -labelpos nw \ + -command { focus [.passwd component entry] } +pack .login -padx 4 -pady 4 + +iwidgets::entryfield .passwd -labeltext "Password:" -labelpos nw -show "\267" \ + -command { focus [.phone component entry] } +pack .passwd -padx 4 -pady 4 + +iwidgets::entryfield .phone -labeltext "Phone:" -labelpos nw \ + -command { focus [.login component entry] } \ + -validate {check_phonenum %W "%c"} +pack .phone -padx 4 -pady 4 + +proc check_phonenum {entry char} { + set current [$entry get] + set len [string length $current] + if {$len == 3 || $len == 7} { + $entry delete 0 end + $entry insert 0 "$current-" + } + if {$len < 12 && [string match {[0-9]} $char]} { + return 1 + } + return 0 +} |