Re-calling the same card?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re-calling the same card?
Sorry Folks, I think this might be a long explanation for something which probably has a simple solution...
I have a card called "news" which displays a news article. The specific article is selected from an sqlite database depending on the content of a global variable.
I want to be able to scroll thru the articles in the database by swiping left and right for next and previous.
What I thought I could do was increment/decrement the value in the global variable, and then re-call the same "news" card, with the appropriate push effect.
But nothing happens. I'm guessing the "news" card's openCard handler is not being called because the card is already open.
I have a couple of workarounds but they are not elegant.
I have a "dummy" card which I call with no visual effect, and this then re-calls the "news" card with the left/right push effect. This works, except there is brief flash as the dummy card is displayed, so it doesn't quite look like the correct push effect.
Or, I guess I could have two almost-identical news cards, where news1 calls news2, and news2 calls news1.
But I bet I'm missing something, and there is an elegant way to re-call an open card.
TIA
--paul
I have a card called "news" which displays a news article. The specific article is selected from an sqlite database depending on the content of a global variable.
I want to be able to scroll thru the articles in the database by swiping left and right for next and previous.
What I thought I could do was increment/decrement the value in the global variable, and then re-call the same "news" card, with the appropriate push effect.
But nothing happens. I'm guessing the "news" card's openCard handler is not being called because the card is already open.
I have a couple of workarounds but they are not elegant.
I have a "dummy" card which I call with no visual effect, and this then re-calls the "news" card with the left/right push effect. This works, except there is brief flash as the dummy card is displayed, so it doesn't quite look like the correct push effect.
Or, I guess I could have two almost-identical news cards, where news1 calls news2, and news2 calls news1.
But I bet I'm missing something, and there is an elegant way to re-call an open card.
TIA
--paul
Re: Re-calling the same card?
try:
lock screen
<load new content here>
unlock screen with visual effect push left <or right>
lock screen
<load new content here>
unlock screen with visual effect push left <or right>
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Re-calling the same card?
Nope, that didn't help Jacqueline. Absolutely nothing happens when I swipe ... with or without lock screen.jacque wrote:try:
lock screen
<load new content here>
unlock screen with visual effect push left <or right>
Any other thoughts?
--paul
Re: Re-calling the same card?
If your content loads only on opencard then you'd need to move that process to its own handler. On opencard, call the handler. Then call the handler again in between lock screen messages when you need to load new content.
Alternately you can just call "opencard" from another handler.
It would be informative to see your scripts.
Alternately you can just call "opencard" from another handler.
It would be informative to see your scripts.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Re-calling the same card?
Thanks Jacqueline. Yes, the content loads on openCard. I thought about moving the code into another handler, but can I get then the visual effect?jacque wrote:If your content loads only on opencard then you'd need to move that process to its own handler. On opencard, call the handler. Then call the handler again in between lock screen messages when you need to load new content.
Alternately you can just call "opencard" from another handler.
It would be informative to see your scripts.
There's not much to see in the code. I've tried...
Code: Select all
command goNextArt
put g_sel_btnnbr + 1 into g_sel_btnnbr
if g_sel_btnnbr < g_tot_disp then
go card "dummy_page_n"
else
put g_sel_btnnbr - 1 into g_sel_btnnbr
end if
end goNextArt
If I do...
Code: Select all
command goNextArt
put g_sel_btnnbr + 1 into g_sel_btnnbr
if g_sel_btnnbr < g_tot_disp then
lock screen
go "article_page" -- this card is "article_page"
unlock screen with visual effect push left
else
put g_sel_btnnbr - 1 into g_sel_btnnbr
end if
end goNextArt
... then the swipe gesture does nothing.
But if I try...
Code: Select all
command goNextArt
put g_sel_btnnbr + 1 into g_sel_btnnbr
if g_sel_btnnbr < g_tot_disp then
lock screen
openCard
unlock screen with visual effect push left
else
put g_sel_btnnbr - 1 into g_sel_btnnbr
end if
end goNextArt
So, I'm getting closer, but still not there. Learning more every day...
--paul
Re: Re-calling the same card?
Forgive the inline answers:
If you had used the "lock screen for visual effect" form of lock screen from the dummy card with unlock screen with visual effect push left, you would see an empty screen pushing left and ending up showing the other card. Since the visual effect was not working you just see the flash of white then the other card.
lock screen for visual effect
and adding a line:
opencard
should solve that issue.
To use the "dummy" method change your code to something like this.Code: Select all
command goNextArt put g_sel_btnnbr + 1 into g_sel_btnnbr if g_sel_btnnbr < g_tot_disp then go card "dummy_page_n" else put g_sel_btnnbr - 1 into g_sel_btnnbr end if end goNextArt
Code: Select all
command goNextArt
put g_sel_btnnbr + 1 into g_sel_btnnbr
if g_sel_btnnbr < g_tot_disp then
lock screen for visual effect -- must specify the for visual effect. In this case its the whole screen so I just use lock screen
go card "dummy_page_n" -- change to dummy.
go card "theMainCard" -- change back to your main card and opencard will fire. No code is necessary in dummy.
unlock screen with visual effect push left -- do the visual effect
else
put g_sel_btnnbr - 1 into g_sel_btnnbr
end if
end goNextArt
The white flash is because you go to the dummy page which I assume is blank, and do the lock screen from there. (i think)
...where dummy_page_n re-calls article_page with the push left effect. That works, except, as I mentioned, there is white flash as dummy_page_n loads, so that's not ideal.
If you had used the "lock screen for visual effect" form of lock screen from the dummy card with unlock screen with visual effect push left, you would see an empty screen pushing left and ending up showing the other card. Since the visual effect was not working you just see the flash of white then the other card.
As mentioned, the above code doesn't change a) because you don't lock screen for visual effect. And b) because opencard doesn't fire. Changing the lock line to:If I do...
Code: Select all
command goNextArt put g_sel_btnnbr + 1 into g_sel_btnnbr if g_sel_btnnbr < g_tot_disp then lock screen go "article_page" -- this card is "article_page" unlock screen with visual effect push left else put g_sel_btnnbr - 1 into g_sel_btnnbr end if end goNextArt
... then the swipe gesture does nothing.
lock screen for visual effect
and adding a line:
opencard
should solve that issue.
For this one, see the answer just above. (lock screen for visual effect)But if I try...
... I correctly display the next article, but I do not see the visual effect.Code: Select all
command goNextArt put g_sel_btnnbr + 1 into g_sel_btnnbr if g_sel_btnnbr < g_tot_disp then lock screen openCard unlock screen with visual effect push left else put g_sel_btnnbr - 1 into g_sel_btnnbr end if end goNextArt
So, I'm getting closer, but still not there. Learning more every day...
--paul
Re: Re-calling the same card?
most of quote snipped...
--paul
Many thanks ... I learned a lot from your comprehensive answer. The solution I picked is the "lock screen for visual effect" which works just fine.sturgis wrote: For this one, see the answer just above. (lock screen for visual effect)
--paul