Navbar widget highlight on app reopen

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Navbar widget highlight on app reopen

Post by jekyllandhyde »

I have grouped the navigation bar widget that functions well.... That is until I press the home button on the iPhone which closes the app. On app reopen I use the following code:

Code: Select all

 --this displays last card when a user re-starts the App
on preOpenStack   
put specialfolderpath("documents") & "/lastplace" into thefile
   if there is not a file thefile then
      put empty into URL ("file:" & thefile)
   else
      put URL ("file:" & thefile) into thelastPlace
      go card id theLastPlace
   end if
end preOpenStack
The problem is that the navigation bar widget that is highlighted when the card opens is always the same one, in my case from card "1" of the stack. This although the correct "saved" card is showing. So I have a mismatch between card shown and icon highlighted. It corrects itself after clicking another icon.

Not sure how to resolve this? thx.
jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Navbar widget highlight on app reopen

Post by jekyllandhyde »

Solved my own problem, if you have the same here's a fix:

Code: Select all

on preopencard
   set the hilitedItem of widget "navbar" of group "navgroup" to 3
end preopencard
Just set the hilitedItem of the widget to the number corresponding to whichever card you are opening. Now you can return to a card after shutting down the app and have the appropriate icon highlighted.
Batninja
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 55
Joined: Sat Oct 15, 2011 9:43 am

Re: Navbar widget highlight on app reopen

Post by Batninja »

Very helpful, many thanks for your code - maybe this should be in the blog post about the Navigation Bar widget or the comments anyway.
peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm

Re: Navbar widget highlight on app reopen

Post by peter-b »

I've filed a bug report about this issue: http://quality.livecode.com/show_bug.cgi?id=18842
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com
Post Reply