Keeping fields hilited when returning from another card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 5
- Joined: Sun Dec 13, 2009 2:18 am
Keeping fields hilited when returning from another card
I am sure there must be a way to do this.
When I select a line on a field with a list, I can hilite the line. But if I go to another card, then return to the original card, the field is no longer hilited. What am I doing wrong? I would be grateful for any advice.
When I select a line on a field with a list, I can hilite the line. But if I go to another card, then return to the original card, the field is no longer hilited. What am I doing wrong? I would be grateful for any advice.
-
- VIP Livecode Opensource Backer
- Posts: 4028
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Keeping fields hilited when returning from another card
Hello NewRevUser1440,
Welcome to the forum.
I think it is 'normal' for a field selection to be not persistent when leaving a card. Otherwise you would preset choices for the user, which might confuse him.
I did a script that lets you restore the selection in the list field/fields that had one/more selection. You know what your field looks like, but one can have more than one list field and the fields can have no, one or multiple selections.
The script looks a bit intimidating at first because it tries to take into account all the possibilities. I did not find an easier way.
It makes use of several things in Rev that are not obvious at first and you might want to look this up in the dictionary and user guide.
script local variable
array, array keys
repeat for each (chunk like line, item, or whatever) in a variable
I commented heavily in the script so hopefully it is clear what happens.
You would have to place this code into the script of every card that has list fields you want to have remembered.
regards
Bernd
Welcome to the forum.
I think it is 'normal' for a field selection to be not persistent when leaving a card. Otherwise you would preset choices for the user, which might confuse him.
I did a script that lets you restore the selection in the list field/fields that had one/more selection. You know what your field looks like, but one can have more than one list field and the fields can have no, one or multiple selections.
The script looks a bit intimidating at first because it tries to take into account all the possibilities. I did not find an easier way.
It makes use of several things in Rev that are not obvious at first and you might want to look this up in the dictionary and user guide.
script local variable
array, array keys
repeat for each (chunk like line, item, or whatever) in a variable
I commented heavily in the script so hopefully it is clear what happens.
You would have to place this code into the script of every card that has list fields you want to have remembered.
Code: Select all
-- script local variables are declared outside of any handler in
-- the script. They persist between calls and can be accessed by
-- any handler in the script. They are not stored when closing the stack
local tLastHilite
on closeCard
put "" into tTest
put "" into tLastHilite
repeat with i = 1 to the number of fields
put the hilitedLines of field i into tTest
-- if tTest is not empty then put it into an array
-- the array is created by using array notation
-- like put something into myArray[anIndex]
if tTest <> "" then put tTest into tLastHilite[i]
put "" into tTest
end repeat
end closeCard
on openCard
-- if tLastHilite is not an array then it was not
-- filled on closecard so passing opencard
-- ends the opencard handler here, same as exit opencard
-- except other handlers further in the message hierarchy
-- can still handle a opencard message. If you say 'exit opencard'
-- the message is not passed
if not tLastHilite is an array then pass opencard
-- we get the keys = indexes of the array. In this case the index
-- is the field number so we can address that field by the number
put the keys of tLastHilite into tmyKeys
repeat for each line aKey in tmyKeys --aLine contains the text of one line of the keys
-- the array stores the hilitedLines (can be more than one) as a comma separated list
-- and we select this comma separated list of field
set the hilitedLines of field aKey to tLastHilite[aKey]
end repeat
-- the array is cleared by putting empty into it
-- and is no longer an arry, just a ordinary local variable
put "" into tLastHilite
end openCard
Bernd
-
- Posts: 5
- Joined: Sun Dec 13, 2009 2:18 am
Re: Keeping fields hilited when returning from another card
Thank-you for your help. I do want to preset some choices as defaults. My stack was imported from a hypercard stack where fields do stay hilited when you leave, then return. It seems strange to me that Rev fields don't do this. Thanks again.
-
- VIP Livecode Opensource Backer
- Posts: 4028
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Keeping fields hilited when returning from another card
NewRevUser1440,
depending on your stack wouldn't a combo box or option menu or a checkbox/radio button be a more consistent user interface?
Hypercard as far as I remember did not have as many interface elements to choose from.
regards
Bernd
edit: if you want to use this on a stack where you have a lot of cards with the same problem, i.e. the hilite of the list field disappears one would probably change above script to avoid having to put it on every card. If it is only one or two cards that need this behaviour I would leave it as it is. If you need help with this just ask.
depending on your stack wouldn't a combo box or option menu or a checkbox/radio button be a more consistent user interface?
Hypercard as far as I remember did not have as many interface elements to choose from.
regards
Bernd
edit: if you want to use this on a stack where you have a lot of cards with the same problem, i.e. the hilite of the list field disappears one would probably change above script to avoid having to put it on every card. If it is only one or two cards that need this behaviour I would leave it as it is. If you need help with this just ask.
-
- Posts: 5
- Joined: Sun Dec 13, 2009 2:18 am
Re: Keeping fields hilited when returning from another card
Hmm, I will try some of these other options too. I am still learning about how it all works. Thanks for your input.
Re: Keeping fields hilited when returning from another card
Hi 1440 (MacBook? )
check and work through this:
http://www.runrev.com/developers/lesson ... nferences/
Great resources, now finally online again!
Best
Klaus
check and work through this:
http://www.runrev.com/developers/lesson ... nferences/
Great resources, now finally online again!
Best
Klaus
-
- Posts: 5
- Joined: Sun Dec 13, 2009 2:18 am
Re: Keeping fields hilited when returning from another card
Thanks! Looks like a great resource. I appreciate your help.
Re: Keeping fields hilited when returning from another card
And if you need the hilites to be persistent from one session to the next (i.e., stack is closed then reopened later), you can save the tHilitedLines variable as a card or stack property.
when you reopen the card or stack, load the variable from the card/stack property
then execute the rest of the script as it was.
Code: Select all
set the _tHilitedLines of this card to tHilitedLines
Code: Select all
put the _thilitedLines of this card into tHilitedLines
-
- Posts: 5
- Joined: Sun Dec 13, 2009 2:18 am
Re: Keeping fields hilited when returning from another card
For my current project, I only need the hilited lines of my fields to persist as I move to another card than back again.I don't need to persist after I close the stack. However I will keep your suggestion in mind for other projects. Thanks for your help.
I am presently putting the mouseline from my hilited fields into a storage field on each card, then retreiving that to hilite the line I need when I return from another card. Sometimes my scripts need to pre-select lines on another card depending on choices made, and this works well because I can just change the info on the storage field to make it select the fields as I need them. I could also use variables instead of storing the info in a field, but this works for now because I can see which line needs to be changed. Not elegant I know, but I'm a beginner. LOL!
I am presently putting the mouseline from my hilited fields into a storage field on each card, then retreiving that to hilite the line I need when I return from another card. Sometimes my scripts need to pre-select lines on another card depending on choices made, and this works well because I can just change the info on the storage field to make it select the fields as I need them. I could also use variables instead of storing the info in a field, but this works for now because I can see which line needs to be changed. Not elegant I know, but I'm a beginner. LOL!