Silvia,

You need to patch the feel object of your field so that engage takes 
the max length into account when it processes keyboard input.

Here is a rough example of a field which stops accepting characters 
after the 10th. You could include something similar in your style definition

lt: layout [
mxfld: field feel [
         engage: func [face act event] [
             switch act [
                 down [
                     either not-equal? face system/view/focal-face [
                         focus face
                         system/view/caret: offset-to-caret face event/offset
                     ] [
                         system/view/highlight-start:
                         system/view/highlight-end: none
                         system/view/caret: offset-to-caret face event/offset
                     ]
                     show face
                 ]
                 over [
                     if not-equal? system/view/caret offset-to-caret 
face event/offset [
                         if not system/view/highlight-start 
[system/view/highlight-start: system/view/caret]
                         system/view/highlight-end: 
system/view/caret: offset-to-caret face event/offset
                         show face
                     ]
                 ]
                 key [
                     if any [
                         face/max-len > length? face/text
                         event/key = #"^M"
                         event/key = #"^~"
                         event/key = #"^H"
                         event/key = #"^-"
                         event/key = 'left
                         event/key = 'right
                     ] [
                         system/words/ctx-text/edit-text face event 
get in face 'action
                     ]
                 ]
             ]
         ]
     ] with [max-len: 10]
]
view lt

I use something similar in my style definition

Hope this help,
Louis


At 08:49 AM 2005-12-12, you wrote:
>Hi List,
>
>I've got one, simple (hope), question for you.
>
>I need to manage input and I would like to know if 'field could be set with
>a max length to make sure that when I'll write my data on the DB, strings
>will be non longer than what defined in my table.
>
>If a refinement like this exists, how is called? If there's no such a
>refinement is there a little function I can use to control my input or
>should I write it alone?
>
>Thank you, Silvia
>
>
>
>--
>To unsubscribe from the list, just send an email to
>lists at rebol.com with unsubscribe as the subject.

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to