newbie q : value & label in text-lists
[1/7] from: sags:apollo:lv at: 31-Mar-2004 0:25
Hi, List!
I would like to set up text-list in my layout, so it
shows just labels, but when selected I could get
value.
Like in HTML forms:
<OPTION SELECTED VALUE="ID">Label 1</OPTION>
I tried some variants by using data blocks, but not
yet success.
thanks
brds
Janek
[2/7] from: ammon:addept:ws at: 30-Mar-2004 18:34
how about something like...
data: ["one" 1 "two" 2 "three" 3]
view layout [
text-list "One" "Two" "Three" [print data/:value]
]
HTH!
~~Ammon ;~>
[3/7] from: Gary:Jones:usap:gov at: 31-Mar-2004 14:38
Hi, "brds Janek",
....
> I would like to set up text-list in my layout, so it
> shows just labels, but when selected I could get
> value.
....
I suspect that there are several ways. Here is one:
data: ["Label 1" "Value 1" "Label 2" "Value 2"]
labels: copy []
foreach [label value] data [append labels label]
view layout [
text-list data labels [
t/text: copy select data value
show t
]
t: text 200x24
]
--Scott Jones
[4/7] from: carl:cybercraft at: 31-Mar-2004 13:39
On 31-Mar-04, [sags--apollo--lv] wrote:
> Hi, List!
> I would like to set up text-list in my layout, so it
<<quoted lines omitted: 4>>
> I tried some variants by using data blocks, but not
> yet success.
face/lines provides an index to which line in the list has just been
clicked on, so that can be used as a pointer to your data. There's
also a face/user-data which could be used to store your values.
Using this approach, you could have something like this...
REBOL []
my-labels: [
"ten"
"eleven"
"twelve"
"thirteen"
"fourteen"
"fifteen"
"sixteen"
"seventeen"
"eighteen"
"nineteen"
]
my-data: [10 11 12 13 14 15 [this is number 16] 17 18 19]
view layout [
text-list 200x70 data my-labels user-data my-data [
probe pick face/user-data index? face/lines
]
]
(The [this is number 16] is just to show you you could have any data
you like in my-data.)
HTHs.
--
Carl Read
[5/7] from: sags:apollo:lv at: 1-Apr-2004 0:11
Thanks for answers!
The next q. is about faces event handling:
I would like to use a layout (form) without help of mouse.
There was some points in couple of documentation files (view
quide and handling events), but no so much.
So I am interested to find some more detailed description or
some examples about tabing (focusing) throught faces (not just
text fields) and more info about "detect" event using.
Could you please point me to a link that I missed.
brgds
Janeks
On 31 Mar 2004 at 21:16, Carl Read wrote:
On 31-Mar-04, [sags--apollo--lv] wrote:
> Hi, List!
> I would like to set up text-list in my layout, so it
<<quoted lines omitted: 4>>
> I tried some variants by using data blocks, but not
> yet success.
face/lines provides an index to which line in the list has just
been
clicked on, so that can be used as a pointer to your data.
There's
also a face/user-data which could be used to store your values.
Using this approach, you could have something like this...
REBOL []
my-labels: [
"ten"
"eleven"
"twelve"
"thirteen"
"fourteen"
"fifteen"
"sixteen"
"seventeen"
"eighteen"
"nineteen"
]
my-data: [10 11 12 13 14 15 [this is number 16] 17 18 19]
view layout [
text-list 200x70 data my-labels user-data my-data [
probe pick face/user-data index? face/lines
]
]
(The [this is number 16] is just to show you you could have any
data
you like in my-data.)
HTHs.
--
Carl Read
[6/7] from: antonr:lexicon at: 1-Apr-2004 16:28
I'm working on a document (draft) which will get
you going. See bottom.
Anton.
> Thanks for answers!
> The next q. is about faces event handling:
<<quoted lines omitted: 7>>
> brgds
> Janeks
How to add tab-key handling to your custom style
Anton Rolls 11-Mar-2004
ToDo:
- continue to try to make an example based on blank-face
- make better the example based on button
- tip: focus sets the caret and text highlight, which we probably don't
want in the button,
so we can just do some of what focus does for our purpose (but it will
add more code)
--------------------------
Set style facet
- style: 'scroll-table,
Add 'tabbed to flags block
- flags: [tabbed]
Modify feel/engage
- trap tab key
- focus either event/shift [ctx-text/back-field face][ctx-text/next-field
face]
Modify feel/redraw
- test if face is currently the focal-face, draw it differently (when action
= 'show)
Modify init
- clone edge if it is used in redraw to show focused state
--------------------------
view center-face layout [
style my-button button with [
style: 'my-button
flags: [tabbed]
init: [edge: make edge []]
feel: make feel [
append second :redraw bind [
if act = 'show [
face/edge/color: either face = system/view/focal-face [yellow][black]
]
] first first third second :redraw
insert skip tail second :engage -5 bind [
if all [
action = 'key
event/key = tab ; #"^-"
][
focus either event/shift [
ctx-text/back-field face
][
ctx-text/next-field face
]
]
] second second :engage
]
]
button "normal"
a: my-button "hello"
b: my-button "there"
do [focus b]
field
]
--------------------------
Credits to Frank Sievertsen for his prior work (see nd-styles.r)
[7/7] from: carl:cybercraft at: 1-Apr-2004 8:40
On 01-Apr-04, [sags--apollo--lv] wrote:
> Thanks for answers!
> The next q. is about faces event handling:
<<quoted lines omitted: 5>>
> text fields) and more info about "detect" event using.
> Could you please point me to a link that I missed.
It sounds like you missed this one...
http://www.rebol.com/how-to/feel.html
which covers event handling quite well. I don't know of any docs
where focusing is explained, but the current focus can be found in
system/view/focal-face. Here's a little example of the focus
rotating automatically through three fields...
rebol []
view layout [
backdrop rate 1 feel [
engage: func [face action event][
either all [
action = 'time
system/view/focal-face
object? f: system/view/focal-face/user-data
][
focus f
][
unfocus
]
]
]
f1: field
f2: field
f3: field
do [
f1/user-data: f2
f2/user-data: f3
f3/user-data: f1
]
]
To start the cycling, click on any field.
The feel (ie, event-handling) is added to the layout's backdrop. To
do the cycling it could've been added to any face since the cycling
is dependant on a timer, not a click on a specific face, but by using
the backdrop we can make it so a click on it will do an unfocus and
so end the cycling.
Hope this gets you started.
Oh yes, and welcome to the mailing-list and REBOL. Both are a lot of
fun as well as being very useful. ;-)
--
Carl Read
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted