button tab object

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

button tab object

Post by kotikoti » Sat Sep 06, 2008 2:03 am

Hi all,
Please advice on how I can script the button tab object to always open on a given tab, it appears that, when I select a tab and close that application/stack, on next opening of the stack/card, the last selected tab is the one in view.


Regards
Koti2
Build 160
Version 2.9.0
Platform: Windows

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: button tab object

Post by bangkok » Sat Sep 06, 2008 8:00 am

kotikoti wrote:Hi all,
Please advice on how I can script the button tab object to always open on a given tab, it appears that, when I select a tab and close that application/stack, on next opening of the stack/card, the last selected tab is the one in view.
I use :

Code: Select all

set menuhistory of button "tab menu" to TheNumberOfTheTabYouWantToDisplay
Something that you can put into opencard handler.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sat Sep 06, 2008 11:31 am

There are actually two things that come into play:
1. the tabbed button will retain the value from when it was last saved;
2. a stack isn't really removed from memory when you close it so when you reopen it, everything will be in the status it was in when it was closed.

The easiest solution to cover both circumstances, is to add something like this to your card script:

Code: Select all

on preOpenCard
  set the menuHistory of button "Tabbed Button" to 1
  pass preOpenCard
end preOpenCard
By setting the menuHistory property of a tabbed button to a number, you choose that 'tab' - doing it in a 'preOpenCard' handler means it happens before the card is displayed, so you don't get any visible transition.

Note that setting the 'menuHistory' property will send the 'menuPick' message to your tabbed button.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

Post by kotikoti » Sat Sep 06, 2008 11:22 pm

Thanks chaps for this...
Works perfectly, learning more each day...

Janschenkel: on item 2, "a stack isn't really removed from memory ", is this also for a standalone?
If so, when traversing a program using several substack's is it then recommended to close them to reduce memory usage, again thinking aloud on this for I haven't reached that stage as yet..

Koti2
Build 160
Version 2.9.0
Platform: Windows

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sun Sep 07, 2008 10:54 am

The behaviour is the same accross the Revolution IDE and the standalones that you create: a stack is indeed not removed from memory unless you set its 'destroyStack' property to 'true' - which may sound alarming, but all it means is that the memory associated with a stack is freed when you close the stack.

Unless you're using huge stacks of several hundreds of megabytes, you're not going to get hurt by the engine's holding onto a stack in memory. And it's not like the memory will slowly fill up - when you re-open the stack, it doesn't spawn a new copy but re-uses the previous copy, sparing the user from loading time and memory.

Where it is important to use this property, is in situations where your stacks are actually 'editor windows' - if you're building a 'document-based' application similar to Excel or Word, where you open and close documents while the application may stay open for weeks.

Hope this clarified the memory retention,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

Post by kotikoti » Wed Sep 10, 2008 2:35 pm

Thanks Janschenkel, keeping this noted for future reference.
Build 160
Version 2.9.0
Platform: Windows

Post Reply