Page 1 of 1
Hardware Backkey
Posted: Wed Mar 05, 2014 3:04 am
by saviour
Hi there,
I referred to browser sample lesson. I have app with two card- one with button and another has "browser" group. Well, I know, back key can be assigned two functionalities-
1. "retreat" inside the browser to go to previous page
2. "go recent or back" to go to card that opened the browser.
My question is can I create if /else function so that the back button retreat inside the browser and go to first card if it reaches the top page or layer, whatever, of the browser like this:
on backkey
If on the top layer of the group "browser" than <------This is wrong

Need correct code here
go recent
else doAction "retreat"
end backkey
Please help.
Re: Hardware Backkey
Posted: Wed Mar 05, 2014 4:34 am
by Simon
Hi saviour,
If I understand your question correctly.
I'm thinking you are going to have to watch that browserStartedLoading has started after doAction "retreat".
When you reach the initial page browserStartedLoading isn't triggered.
Simon
Re: Hardware Backkey
Posted: Wed Mar 05, 2014 4:51 am
by saviour
Hi Simon,
Thanks.
You always come to rescue. Yeah..its like that. Inside the browser, I want back key to "retreat" all the way to firstmost webpage and after reaching the first page, move to "recent" card. Having only "doAction retreat" code in back key will take only to firstmost page then it stucks. So please help.

Re: Hardware Backkey
Posted: Wed Mar 05, 2014 5:40 am
by Simon
OK I have something working.
Add a global gEnd and in the browserStartedLoading set the global to true.
Code: Select all
on backKey
put false into gEnd
doAction "retreat"
send firstPage to me in 250 millisec
end backKey
on firstPage
if gEnd= false then
go cd 2
end if
end firstPage
See how that works?
Simon
Re: Hardware Backkey
Posted: Wed Mar 05, 2014 3:08 pm
by saviour
Thanks Again..
Now tried it..it is not working, fully
With above script, backkey will take me to card 2 direct from the browser. While changing the portion of the same. as below, I can roam within the browser but cannot exit to card 2.-
on firstPage
if gEnd= true then
go cd 2
end if
end firstPage
I also tried these:
(1)on backKey
if gEnd= false then
doAction "retreat"
else go cd 2
end backKey (result is goes to card 2)
(2)on backKey
if gEnd= true then
go cd 2
else doAction "retreat"
end backKey (result is retreat within the browser )
Can u please look what is going wrong here??? Thanks..
Re: Hardware Backkey
Posted: Wed Mar 05, 2014 3:42 pm
by Klaus
You never put any VALUE into gEnd in all of your 3 scripts!?
So gEnd is never TRUE or FALSE!
Better read Simons script again

Re: Hardware Backkey
Posted: Wed Mar 05, 2014 8:17 pm
by saviour
Well I tried many variations but could not succeed. Please help.
on browserStartedLoading pUrl
set the gEnd of me to "home"
end browserStartedLoading
on backKey
if gEnd is not "home" then
doAction "retreat"
send firstPage to me in 250 millisec
end if
end backKey
on firstPage
if gEnd is not "home" then
go cd 2
end if
end firstPage
well I always end up in card 2

Re: Hardware Backkey
Posted: Wed Mar 05, 2014 8:20 pm
by Simon
You forgot to set gEnd to something else in backKey.
The browserStartedLoading is correct.
Simon
Edit; Also you are using a custom property, you have to state "of me" each time it's called.
Re: Hardware Backkey
Posted: Thu Mar 06, 2014 5:03 am
by saviour
Thanks guys. I tried, even in many variations of scripts, but I think it is not doable.
on browserStartedLoading pUrl
set the gEnd of me to "home"
By setting above variable, whenever a new webpage opens within old webpage, above variable is set to true. So backkey either functions as "retreat" when variable is set to true or functions "go cd2" when it is set to false. So it is not working.
May be by putting some check (like creating a global variable) at the time when card opens the browser group (webpage) helps!!! I am just learning

, so can it done like that ??
Thanks!!!
Re: Hardware Backkey
Posted: Thu Mar 06, 2014 5:10 am
by Simon
Hey saviour,
You really are ignoring the first line of on backKey.
Why did I write that?
What does it do?
What will change that cp or var back to a different state?
Simon
Edit, I have tested this and it is working.