Page 1 of 1

Android back button (Solved)

Posted: Wed Sep 02, 2020 12:42 pm
by EddieLee
Hi all,

I have a cd “homepage” and a cd “editpage”. There’s a code in the card script on my cd “editpage” that states:

Code: Select all

On backkey 
Go to cd “homepage”
End backkey 
So what I’m trying to do now is when the user clicks on the back button in cd “editdishes” I do not want the preopencard handler of cd “homepage” to run, or I only want parts of the code to run. Is there any script that I can write on the preopencard handler that let livecode know that it just came from Backkey handler of cd “editpage”?

Re: Android back button

Posted: Wed Sep 02, 2020 1:38 pm
by jmburnod
Hi EddieLee,
Yes, you have to store the name of the closed cd into a variable or customprop and use this on your preopencard message.
Something like that:

backs btn script

Code: Select all

global gMyPrevCD
on mouseup
   put the short name of this cd into gMyPrevCD
end mouseup
homepage script

Code: Select all

global gMyPrevCD
on preopencard
   if gMyPrevCD = “editdishes” then -- gMyPrevCD is the name of a global variable
      
   else
     -- do something
   end if
   put empty into gMyPrevCD -- don't forget to reset variable
end preopencard
Best regards
Jean-Marc

Re: Android back button

Posted: Wed Sep 02, 2020 1:46 pm
by Klaus
Just use RECENT CARD!

Code: Select all

on preopencard
   if the short name of recent cd = “editdishes” then
     ## Do this
   else
     ## Do something else
   end if
end preopencard

Re: Android back button

Posted: Thu Sep 03, 2020 7:49 am
by EddieLee
Hi all,

Thanks everyone for your help! Totally forget about the recent card codes T.T