Scrolling List loses selection when switching card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Scrolling List loses selection when switching card
When I put a List on Card 1 and selection of an item in that list + button click goes to Card 2, clicking back from Card 2 to Card 1 then shows the selected item on the List is now no longer selected. How can I make it hold selection when switching cards?
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Scrolling List loses selection when switching card
listField contains this script:
on mouseUp
put the selectedLine of me into fld "SELECTION"
end mouseUp
The script to make sure the line is reselected when you return to this card is in the cardScript:
The
on mouseUp
put the selectedLine of me into fld "SELECTION"
end mouseUp
The script to make sure the line is reselected when you return to this card is in the cardScript:
Code: Select all
on openCard
put fld "SELECTION" into XXX
select XXX
end openCard
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Scrolling List loses selection when switching card
Set the field's sharedText to true, place it in a group, set the group's sharedBehavior and backgroundBehavior to true.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Scrolling List loses selection when switching card
While I am quite sure that is a far more elegant solution than my one,Set the field's sharedText to true, place it in a group, set the group's sharedBehavior and backgroundBehavior to true.
could you possibly rephrase it in a somewhat less opaque fashion so
us "bottom feeders" could understand it.

-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Scrolling List loses selection when switching card
These are properties available in the Inspector. Throughout LiveCode, as with many dev tools, objects have properties which govern common behavior. That set of property settings addresses the OP's need. For details on each they're described betterin the Dictionary than I could replicate here.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Scrolling List loses selection when switching card
I did all that but it doesn't work here I'm afraid, though I have vague memories that it used to. I had to do this:FourthWorld wrote: ↑Sat Mar 24, 2018 4:59 pmSet the field's sharedText to true, place it in a group, set the group's sharedBehavior and backgroundBehavior to true.
In field script:
Code: Select all
on mouseUp
set the cLine of me to the hilitedline of me
go next
end mouseUp
Code: Select all
on preOpenControl
set the hilitedline of fld 1 of me to the cLine of fld 1
end preOpenControl
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Scrolling List loses selection when switching card
Does this mean that hilitedLine is a synonym for selectedLine ?
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Scrolling List loses selection when switching card
I used to do that, and double-checked before posting to make sure a property-only approach would work. It does here in v9RC1, at least under Ubuntu 14.04. Just to make sure I just ran the recipe again - continues to work.jacque wrote: ↑Sat Mar 24, 2018 8:44 pmI did all that but it doesn't work here I'm afraid, though I have vague memories that it used to. I had to do this:FourthWorld wrote: ↑Sat Mar 24, 2018 4:59 pmSet the field's sharedText to true, place it in a group, set the group's sharedBehavior and backgroundBehavior to true.
In field script:In group script:Code: Select all
on mouseUp set the cLine of me to the hilitedline of me go next end mouseUp
The preOpenControl handler will only work if the card you're coming from doesn't have that group placed.Code: Select all
on preOpenControl set the hilitedline of fld 1 of me to the cLine of fld 1 end preOpenControl
If the working behavior is limited to a single platform, that would seem a bug. And given how common this need is, it would seem a bug worth addressing.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Scrolling List loses selection when switching card
No. They can sometimes be used in similar tasks, but return very different values. When in doubt the Dictionary contains useful details.richmond62 wrote: ↑Sat Mar 24, 2018 8:51 pmDoes this mean that hilitedLine is a synonym for selectedLine ?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Scrolling List loses selection when switching card
Someone else should check the property method. I tested it as written and it didn't work in 9.rc1 on Mac. I may have missed something though.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Scrolling List loses selection when switching card
I just tested on Mac and got the same good result. What are we doing differently? The complete steps I take are:
1. Create a new stack
2. Create a scrolling list field put
3. Use the Inspector to put some text in it.
4. In the Inspector, set the field's sharedText
5. Group it
6. In the Inspector, set the group's backgroundBehavior and the sharedBehavior
7. Choose browse tool
8. Click a line other than the first one to hilite it
9. Choose "Go Next" from the View menu
RESULT: the line I selected remains selected as I switch cards
1. Create a new stack
2. Create a scrolling list field put
3. Use the Inspector to put some text in it.
4. In the Inspector, set the field's sharedText
5. Group it
6. In the Inspector, set the group's backgroundBehavior and the sharedBehavior
7. Choose browse tool
8. Click a line other than the first one to hilite it
9. Choose "Go Next" from the View menu
RESULT: the line I selected remains selected as I switch cards
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Scrolling List loses selection when switching card
I turned off the group's sharedBehavior and it started working.
Odd, that.
Edit: I just noticed I'm in 8.1.9. I have several versions of LC running and got mixed up.
Odd, that.
Edit: I just noticed I'm in 8.1.9. I have several versions of LC running and got mixed up.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Scrolling List loses selection when switching card
I have only just skimmed this thread, but isn't the easiest way to simply set a custom property of the list field to its hilitedLine , and on openCard, hilite that line?
Craig
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Scrolling List loses selection when switching card
There are many ways to solve many things. We can write custom scripts to mirror most built-in property-driven behaviors if we want to. Personally, I prefer to let the engine do the work where I can, leaving script space free and open for things property settings can't do.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Scrolling List loses selection when switching card
Indeed.There are many ways to solve many things.

set the script of the listField to this:
Code: Select all
on mouseUp
set the LYNE of me to the selectedLine of me
end mouseUp
then in the cardScript:
Code: Select all
on openCard
put the LYNE of fld "myList" into LLINE
select LLINE
end openCard
