list: multiple columns update
[1/6] from: robert::muench::robertmuench::de at: 13-Feb-2002 21:00
Hi, I'm trying to use a list with at least two columns and have the following
supply function in use:
_supply: [
; do we have enough data?
if count > length? project-list [face/show?: false exit]
face/show?: true
; get project
current-project: pick project-list count
; add stripes look to the list
face/color: ivory
if even? count [face/color: ivory - 50.50.50]
; change color if project is selected
### if current-project/selected [face/color: yellow]
; we use the current index to pick the entry from our object to display
; first current-project gives the list of fields in the object
; +1 skips the self reference
field: pick first current-project index + 1
face/text: current-project/:field
; store the project index into the predefined user-data field of the face,
; so that we can later access it
face/user-data: count
]
The line marked with ### should set the color of each column to yellow but only
the first column is displayed with a yellow background color. The other columns
change the color as soon as I click on the face. Why aren't the other faces
color get updated too?
--
Robert M. Münch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax : +49 (0)721 8408 9112
Web : http://www.robertmuench.de
[2/6] from: rebol:optushome:au at: 14-Feb-2002 23:26
Hi Robert,
Here is a simple multilist column example. Hope it helps.
Cheers,
Allen K
REBOL [
Title: {Multi-column List demo}
Author: "Allen Kamp"
]
Data: [
[Left1 Middle1 Right1]
[Left2 Middle2 Right2]
[Left3 Middle3 Right3]
[Left4 Middle4 Right4]
[Left5 Middle5 Right5]
]
selected: row: 0
item: line: none
view layout [
style txt txt [if row [selected: row show lst]] 100
lst: list 300x300 [across space 0x0 txt txt txt] supply [
row: count
either line: pick data count [
item: pick line index
face/text: item
; color our columns
face/color: pick reduce [red blue green] index
; hilight selected row
if row = selected [face/color: gold]
][
; not a row with data set defaults
set-font face 'color black
face/color: snow
face/text: none
]
]
]
[3/6] from: robert:muench:robertmuench at: 14-Feb-2002 18:58
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 3>>
> Subject: [REBOL] Re: list: multiple columns update
> Here is a simple multilist column example. Hope it helps.
Hi, thanks. Yes it does but I have some questions
> view layout [
> style txt txt [if row [selected: row show lst]] 100
What does the [...] block stand for in a style command? Is this the code that
gets executed if a row is clicked?
You use 'row and 'row gets set to 'count within the supply block. So when is the
code in the style definition executed? IMO this can only happen after the supply
block has been exectued so that 'row has a valid value. On the other hand you
use the 'selected value with the 'if in the supply block... This indicates that
the code must be executed before the supply block so that 'selected has a valid
value.
> lst: list 300x300 [across space 0x0 txt txt txt] supply [
> row: count
<<quoted lines omitted: 13>>
> ]
> ]
Here is my code that doesn't work, maybe you find the problem :-|
; The _layout is used in a LIST to specify how the list should look like and
; how many columns it has
; If you want to add an action to some of the fiels just provide a function
; that gets called.
_layout: [
across
space 0
text 20 _project-select text 120
text 120
text 120
text 120
]
_project-select: [
tmp: pick project-list face/user-data
tmp/selected: not tmp/selected
show _list
]
; FUNC [FACE COUNT INDEX]
; face the VID object to work with
; count numbers the rows
; index numbers the columns
_supply: [
; do we have enough data?
if count > length? project-list [face/show?: false exit]
face/show?: true
; get project
current-project: pick project-list count
; add stripes look to the list
face/color: ivory
if even? count [face/color: ivory - 50.50.50]
; change color if project is selected
print [count index current-project/selected]
if current-project/selected [face/color: yellow]
; we use the current index to pick the entry from our object to display
; first current-project gives the list of fields in the object
; +1 skips the self reference
field: pick first current-project index + 1
face/text: current-project/:field
; store the project index into the predefined user-data field of the
; face, so that we can later access it
face/user-data: count
]
list 100x100 _layout supply _supply
Robert
[4/6] from: rebol:optushome:au at: 15-Feb-2002 7:09
----- Original Message -----
From: "Robert M. Muench" <[robert--muench--robertmuench--de]>
To: <[rebol-list--rebol--com]>
Sent: Friday, February 15, 2002 3:58 AM
Subject: [REBOL] Re: list: multiple columns update
> > -----Original Message-----
> > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 7>>
> > style txt txt [if row [selected: row show lst]] 100
> What does the [...] block stand for in a style command? Is this the code
that
> gets executed if a row is clicked?
Yes. This is what gets executed when a face in the list gets clicked.
> You use 'row and 'row gets set to 'count within the supply block. So when
is the
> code in the style definition executed? IMO this can only happen after the
supply
> block has been exectued so that 'row has a valid value. On the other hand
you
> use the 'selected value with the 'if in the supply block... This indicates
that
> the code must be executed before the supply block so that 'selected has a
valid
> value.
Yes. I set 'row to 'count so that I can access that value outside of the
supply func, in this case I do it specifically so we can set 'selected to
the current row/count value when a face is clicked.
There is nothing list specific about using style, I am just using it as a
shortcut to provide the action block to all the columns by creating a style
with that as its action.
I don't have time to check your code now, but will have a look when I get
home. But I suspect that you understand how to fix it now.
Cheers,
Allen
[5/6] from: robert:muench:robertmuench at: 14-Feb-2002 23:19
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
> Robert M. Muench
> Sent: Thursday, February 14, 2002 6:58 PM
> To: [rebol-list--rebol--com]
> Subject: [REBOL] Re: list: multiple columns update
Hi, I further investigated my problem. The problem seems to be that I'm using
panels. So I have something like this:
test: layout [
button "Test"
panel: box 20x20
]
At some other place I'm assigning a layout to panel/pane that holds the list.
...
panel/pane: layout myDialog
Inside myDialog I have the code that handles all kinf of functionallity. I used
a show test at several places but this doesn't seem to update panel (?? why ??)
but if I use show panel instead the display is updated.
But with this some other problem araises. If the dialog is displayed all the
lables have red text?? What does this mean? I think it might a visual feedback
about the parts of the GUI that are marked dirty and need to be updated. Any
idea? Robert
[6/6] from: arolls:idatam:au at: 15-Feb-2002 22:55
Robert, I am sure you are worrying too much!
There is probably init code that initializes
both those values before either of those bits
of code executes.
Sorry I didn't look into it further... :)
probe lst/init
Anton.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted