strange behavior with setting hilitedlines in substack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
strange behavior with setting hilitedlines in substack
I am displaying a substack as a modal window, in order to select a list of items (with multiple selections). The selected items are stored back in a field of the main stack. When the substack is opened, I want to automatically highlite the items that were previously selected and stored in that field. I have written a script, and it "sometimes" works. The substack is opened when I click on a field of the main card:
send "updateList" to card id 1002 of stack "GenreSelection"
toplevel stack "GenreSelection" (I would normally use "modal" but have switched to "toplevel" for testing purposes)
In the "updateList" script, I read the content of the stored list, match it to lines in the substack list field, and highlight the corresponding lines, with this instruction:
set the hilitedlines of field "GenresList2" of card id 1002 of stack "GenreSelection" to cLines
cLines contains the list of items in the format "1,2,3". I have checked that cLines is correctly determined, and if I just replace it with a "constant", I get the same behavior: the lines are not highlighted when the substack is opened the first time, but if i click again on the field of the main card while the substack is open, the update scrip is called again and this time the the highlighting works correctly. If I change the name of the list field in the substack to something else (ex: "GenreList3"), then it works the first time I call the substack, but reverts back to the same behavior after...
Any help would be greatly appreciated!
send "updateList" to card id 1002 of stack "GenreSelection"
toplevel stack "GenreSelection" (I would normally use "modal" but have switched to "toplevel" for testing purposes)
In the "updateList" script, I read the content of the stored list, match it to lines in the substack list field, and highlight the corresponding lines, with this instruction:
set the hilitedlines of field "GenresList2" of card id 1002 of stack "GenreSelection" to cLines
cLines contains the list of items in the format "1,2,3". I have checked that cLines is correctly determined, and if I just replace it with a "constant", I get the same behavior: the lines are not highlighted when the substack is opened the first time, but if i click again on the field of the main card while the substack is open, the update scrip is called again and this time the the highlighting works correctly. If I change the name of the list field in the substack to something else (ex: "GenreList3"), then it works the first time I call the substack, but reverts back to the same behavior after...
Any help would be greatly appreciated!
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: strange behavior with setting hilitedlines in substack
Hi.
The problem may be as simple as this:
Do you have the field's "listBehavior" set? Do you have its "multipleLines" set?
A plain ordinary field will not display what you are asking it to if it does not have those properties set.
Craig Newman
The problem may be as simple as this:
Do you have the field's "listBehavior" set? Do you have its "multipleLines" set?
A plain ordinary field will not display what you are asking it to if it does not have those properties set.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: strange behavior with setting hilitedlines in substack
It could be a couple of things. Instead of trying to set the hilites from the main stack, try doing it from the substack instead. On a preOpenCard or opencard handler, get the cLines of the mainstack and set the hilites from there. The mainstack would simply open the substack and the substack would manage the hilites. If there's a timing problem, that should fix it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: strange behavior with setting hilitedlines in substack
Thanks. The multiple lines property is set for the field. Selecting multiple lines in the field with the mouse works fine.
I will try to put the script in the open card of the substack.
I will try to put the script in the open card of the substack.
Re: strange behavior with setting hilitedlines in substack
Got it to work putting the script in the substack, and removing the reference to the card and substack in the script when adressing the field (don't know why that was an issue). Thanks.
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: strange behavior with setting hilitedlines in substack
I'd guess it was a timing issue. The original handler set the hilites before the stack was open, and then when it did open LC was using its original state. Reversing the two lines in the original mainstack handler would probably fix it too, but then you could see a brief flash as the screen refreshed. Controlling it in the substack avoids that since the update happens after the stack is open and displayed.
That said, I'd think your original script should have worked anyway, in theory.
That said, I'd think your original script should have worked anyway, in theory.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com