On 21-Aug-02, johnfdutcher wrote:
> 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:
>
>> 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.
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 ["Face/text..." face/data face/text]
and you'll see that both data and text remain none regardless of how
many numbers you enter in the fields. As it is, you'd have to check
each field individually to restrict their text lengths. The
following in place of your above line would do this for the num1
field...
if all [num1/data 2 = length? num1/data][inform dialog2]
though only the num1 field. ('all is used so it won't trip up when
data is none. 'all stops looking at the expressions in its block if
false (or none) is returned by any of them, so when num1/data is
none it'll exit before it gets to the expression checking the
length, thus avoiding an error.)
So, you'd need a check like the above for each of your fields, which
would work I guess, but isn't very elegant. Ideally, you should be
altering the fields' feel instead of the global events, but off the
top of my head I'm not sure how to do that. Hope this helps, anyway.
--
Carl Read