Search the web
Sign In
New User? Sign Up
Rebol_New · For beginning Rebol programmers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Calculating size (number of chars. in the string) of data in a 'fie   Message List  
Reply | Forward Message #230 of 315 |
The 'key-event:'function below nicely allows me to 'filter' the
keystrokes into my GUI. So far, no code experiment at the line whose
content (near the end) is:

if 3 > length? to-string face/data [inform dialog2]

successfully allows me to know the number of characters in the 'face'
(a text field) currently entered.
Either nothing happens, (the referenced dialog doesn't open) or there
will be a compile time error.

I include the whole script below since context can be important.
**********************************************************************

Rebol[]

key-event: func [face event] [
either event/type = 'key [
digit: to-string event/key
print switch/default digit [
"0" [event/key]
"1" [event/key]
"2" [event/key]
"3" [event/key]
"4" [event/key]
"5" [event/key]
"6" [event/key]
"7" [event/key]
"8" [event/key]
"9" [event/key]
"^-" [event/key]
"^~" [event/key]
"left" [event/key]
"right" [event/key]
] [inform dialog]
if 3 > length? to-string face/data [inform dialog2]
] []

event
]

dialog: layout [
backdrop effect [gradient 1x1 0.0.0 0.0.180]
h2 "Field size exceeded or invalid character entered:" red
h3 {There can be only two digits in each number window,
and there MUST be two digits.} yellow
h3 {The only other allowable keys are 'tab', 'shift/tab',} yellow
h3 {'left arrow' & 'right arrow' and the 'delete' key} yellow
button "O.K." [hide-popup]
]

dialog2: layout [
backdrop effect [gradient 1x1 0.0.0 0.0.180]
h2 "Field size exceeded:" red
h3 {There can be only two digits in each number window,
and there MUST be two digits.} yellow
button "O.K." [hide-popup]
]
data-form: layout [
size 512x480
backdrop blue
vh1 yellow "Lotto Numbers Checking Form"
box 460x4 168.168.168 across
vtext bold yellow "Enter the (5) winning two-digit numbers, (left
zero for single digits is required):"
return
num1: field with [size: 25x24]
num2: field with [size: 25x24]
num3: field with [size: 25x24]
num4: field with [size: 25x24]
num5: field with [size: 25x24]
return
box 460x4 168.168.168 across
return
vtext bold yellow "Enter the wild card number, (left zero for
single digits is required):"
return
wc: field with [size: 25x24]

return
vtext bold yellow "Press Enter to check above entry against
database of held tickets:"
return
box 460x4 168.168.168 across
return
pad 30
indent 110

button "Enter" [chk-nbrs]
button "Clear" [clear-fields data-form show data-form]

]

chk-nbrs: does [
print ["....Checking existing database of existing tickets"]
]

main-face: system/view/screen-face/pane/1
insert-event-func :key-event
focus num1
view data-form







Tue Aug 20, 2002 5:53 pm

johnfdutcher
Offline Offline
Send Email Send Email

Forward
Message #230 of 315 |
Expand Messages Author Sort by Date

The 'key-event:'function below nicely allows me to 'filter' the keystrokes into my GUI. So far, no code experiment at the line whose content (near the end) is:...
johnfdutcher
Offline Send Email
Aug 20, 2002
5:53 pm

... Hi John, Part of your problem is the face in your function is the window-level face, not the field face. Place this line before the above... print...
Carl Read
lunaread
Offline Send Email
Aug 21, 2002
11:13 am

Carl, You instigated a major step forward...as the suggested line does indeed put up the dialog when a 3rd keystroke is made. Can you comment on this...
johnfdutcher
Offline Send Email
Aug 21, 2002
12:22 pm

... Groan - yes, you're right. I hadn't tested the other fields. Anyway, have a look at the attached script. (Line-wraps can muck up scripts in the body of...
Carl Read
lunaread
Offline Send Email
Aug 21, 2002
11:32 pm

What a really effective piece of work ... and just what I'm looking to find ! Thanks much Carl. I keep hoping Rebol will 'make it'....but suppose time will...
johnfdutcher
Offline Send Email
Aug 22, 2002
12:35 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help