Re: EuGTK - get(view,"row"?)
- Posted by irv Sep 27, 2010
- 940 views
The following lines are from test33.ex.
sequence selected_food = get(view,"text",VEG) integer selected_serv = get(view,"value",SERV) printf(1,"The recommended serving for %s is %d oz.\n",{selected_food,selected_serv})
These lines get the content of the row selected. What I want is to get the row.
Is there such a thing as:
get(view,"row") or something like
Do you want an integer saying that the 5th row from the top has been selected? If so, what good will that do? The 5th row could contain "Aardvaarks" one moment, and "Yaks" the next, if the user sorts the list.
What if the list has been scrolled a bit? Do you select the 5th item showing, or the 5th item from the top of the list? What if the user drags a different item into 5th place? Or adds an item before the 5th?
I can't see where getting the nth item in a list that changes is going to be helpful.
If you lock the list so that it can't be sorted or reordered or items added or removed, then the 5th row is always the same, but then you're being rude to your users.
If you must have a fixed number associated with each item, add a column (doesn't have to be visible) to hold the Euphoria index:
example:
names = { {"Jones",....}, {"Smith",....}, {"Murphy",...} } for i = 1 to length(names) do LV:Row(lv,store,{i,names[i]}) end for
Thus, "Jones" would always carry the index 1 with him, Smith 2, and Murphy 3. You do not have to SHOW the column containing the index number if you do not wish to. But you could get it with
x = get(view,"value",0) -- where 0 is the first column, visible or not.
This will map right back into the original Euphoria sequence "names".
Now, on the other hand, if what you want to get is "all the data in the currently active row", you'll have to write your own loop.
Since the columns of that "row" might contain strings, numbers, spinbuttons, checkbuttons, togglebuttons, comboboxes, images, spinners, progressbars.... Do you want to retrieve the "handle" to the spinbutton, or the value? A function which returns a "row" would have to know things like that.
IF you were to get the "whole row" - you'd still have to extract the data from the items you were interested in. Requesting only the column(s) you need seems more sensible, and is no doubt faster than getting everthing.