Try code at bottom:

Anton.

> 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

view layout [
        style limited-field field with [
                max-length: none ; default is no limit (change this to your 
desired
default)
                feel: make feel []  ; clone the feel so we modify only a copy
                ; add some code after the key handler, binding to 'face
                use [blk][
                        blk: last third second get in feel 'engage ; the block 
in which edit-text
is called
                        append blk bind [
                                if all [
                                        face/max-length
                                        face/max-length < length? face/text
                                ][
                                        clear skip face/text face/max-length
                                        if all [ ; caret needs fixing?
                                                same? head system/view/caret 
head face/text
                                                (index? system/view/caret) > 
face/max-length
                                        ][
                                                system/view/caret: at 
system/view/caret face/max-length
                                        ]
                                        show face
                                ]
                        ] blk/2 ; 'face
                ]
        ]

        field
        limited-field
        limited-field with [max-length: 3]
        limited-field with [max-length: 10]
]


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

Reply via email to