OSDN Git Service

Initial revision
[pf3gnuchains/sourceware.git] / itcl / iwidgets3.0.0 / demos / entryfield
1 #!/bin/sh
2 # ----------------------------------------------------------------------
3 #  DEMO: entryfield in [incr Widgets]
4 # ----------------------------------------------------------------------
5 #\
6 exec itkwish "$0" ${1+"$@"}
7 package require Iwidgets 3.0
8
9 # itkwish interprets the rest...
10 # ----------------------------------------------------------------------
11 option add *textBackground seashell
12 . configure -background white
13
14 iwidgets::entryfield .login -labeltext "Login:" -labelpos nw \
15     -command { focus [.passwd component entry] }
16 pack .login -padx 4 -pady 4
17
18 iwidgets::entryfield .passwd -labeltext "Password:" -labelpos nw -show "\267" \
19     -command { focus [.phone component entry] }
20 pack .passwd -padx 4 -pady 4
21
22 iwidgets::entryfield .phone -labeltext "Phone:" -labelpos nw \
23     -command { focus [.login component entry] } \
24     -validate {check_phonenum %W "%c"}
25 pack .phone -padx 4 -pady 4
26
27 proc check_phonenum {entry char} {
28     set current [$entry get]
29     set len [string length $current]
30     if {$len == 3 || $len == 7} {
31         $entry delete 0 end
32         $entry insert 0 "$current-"
33     }
34     if {$len < 12 && [string match {[0-9]} $char]} {
35         return 1
36     }
37     return 0
38 }