strange behavior with setting hilitedlines in substack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
hopkins
Posts: 41
Joined: Wed Nov 28, 2018 11:09 am

strange behavior with setting hilitedlines in substack

Post by hopkins » Sun Dec 23, 2018 11:47 am

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!

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Sun Dec 23, 2018 6:59 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: strange behavior with setting hilitedlines in substack

Post by jacque » Sun Dec 23, 2018 7:08 pm

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

hopkins
Posts: 41
Joined: Wed Nov 28, 2018 11:09 am

Re: strange behavior with setting hilitedlines in substack

Post by hopkins » Sun Dec 23, 2018 7:28 pm

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.

hopkins
Posts: 41
Joined: Wed Nov 28, 2018 11:09 am

Re: strange behavior with setting hilitedlines in substack

Post by hopkins » Mon Dec 24, 2018 11:46 am

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: strange behavior with setting hilitedlines in substack

Post by jacque » Mon Dec 24, 2018 7:17 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”