[REBOL] Hard to kill key-event....
From: jfdutcher1958::yahoo::com at: 16-Jun-2004 12:39
The code snip below traps key presses nicely......what I don't get is why when
I do: 'return none'
as shown, due to satisfaction of the 'if' statement that checks for
the length of the face field,
the relavant 'face/text' still appears to get updated with the
very character I think I am preventing from getting there....(ala: 'return none').
The next key-event handled re-triggers the same error.
The 'fields' involved (style 'numbox') all show (2) or less characters in them
in the GUI, so the 3rd character never got displayed after 'return none'
which is good ...
but appears to be continuing to affect the length of 'face/text' ???
key-event: func [face event] [
if event/type = 'key [
if ch = 'left [return event]
if ch = 'right [return event]
if ch = #"^-" [return event]
if not find "0123456789" ch [alert "Only digits can be entered" return none]
foreach face lotto-layout/pane [
if face/style = 'numbox [
if 2 < (1 + length? face/text) [alert "Maximum of two digits per box"
if event/type = 'close [
print "Removing event function"