[REBOL] Re: How do I... or Up and Down
From: john_kenyon:mlc:au at: 12-Oct-2001 9:31
Andrew/Mike,
This is a quick addition to Mikes code to pick up the currently selected
item then move up or down. (ie limitation b fixed)
(I'm sure it could be done more concisely, but it works)
;i:1 this line is not needed now
show-pick: func [tl direction] [
either none? find tl/texts tl/picked [ i: 1 ] [
i: index? find tl/texts tl/picked
i: either direction = 'up [i - 1] [i + 1]
i: max 1 min length? tl/data i
]
tl/picked: compose [(pick tl/data i)]
show tl
]
I'll try and fix the scrolling too if I get chance :)
Cheers,
John
Andrew,
This sensor use might be what you want.
---Some limitations:
a. applies to the whole window not just the text-list so
you can't have several together
b. does not interact with previous mouse selections.
c. I don't believe it will scroll a list. at least it does not in easyvid.r
when the list of screens gets long.
---Sample
i: 1
show-pick: func [tl direction] [
i: either direction = 'up [i - 1] [i + 1]
i: max 1 min length? tl/data i
tl/picked: compose [(pick tl/data i)]
show tl
]
view layout [
days: text-list 200x140 data ["Monday" "Tuesday" "Wednesday"
Thursday
Friday
"Saturday" "Sunday"]
sensor keycode [up left] [show-pick days 'up]
sensor keycode [down right] [show-pick days 'down]
]