[REBOL] Re: Text-list updates
From: atruter:labyrinth:au at: 1-Jun-2004 14:26
> I'd love to see the text list respond to keys typed in so that the list
> moves to
> the closest alphabetic word. (Fairly standard long listing behaviour in
> windows etc.)
I'll second that! I've always liked the following "auto-fill" field style
(which I've lost track of who originally wrote, so yell if it's yours).
<code>
stylize/master [
auto-fill: field with [
feel: make feel [
engage: func [face act event index][
switch act [
down [
either face <> system/view/focal-face [
focus face
][
system/view/highlight-start: system/view/highlight-end: none
system/view/caret: offset-to-caret face event/offset
show face
]
]
over [
if 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 [
ctx-text/edit-text face event face/action
if all [
char? event/key
not empty? face/text
find ctx-text/keys-to-insert event/key
][search face]
]
]
]
]
search: func [face /local word][
word: copy face/text
foreach item face/user-data [
if equal? word copy/part item (length? word) [
face/text: copy item
system/view/focal-face: face
system/view/highlight-start: skip face/text length? word
system/view/highlight-end: tail face/text
system/view/caret: tail face/text
show face
exit
]
]
]
words: [data [new/user-data: second args next args]]
]
]
view layout [
a: auto-fill with [
user-data: ["Paul" "Pauline" "Peter"]
]
do [focus a]
]
</code>
Regards,
Ashley