#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" " Managing Tabs 2" /* Tabbed buttons stack By Eric Chatonet 4/11/05 http://www.sosmartsoftware.com/ */ on preOpenStack set the style of this stack to modeless set the loc of this stack to the screenLoc end preOpenStack X Managing Tabbed Buttons U Lucida Grande U Lucida Grande W Lucida Grande W Lucida Grande W Courier U Courier U Courier U Georgia U Georgia U Tahoma U Courier @U Verdana U Verdana Pulldown Menu cREVOnline fingerprint vjpk-KlbY8_eSgEEoGqpAg cREVGeneral scriptChecksum UHD_ debugObjects bookmarks handlerList preOpenStacktempScript prevHandler preOpenStackscriptSelection char 205 to 204script X
/*
Tabbed buttons stack
By Eric Chatonet
4/11/05
http://www.sosmartsoftware.com/
*/
on preOpenStack
set the style of this stack to modeless
set the loc of this stack to the screenLoc
end preOpenStack
p on closeStack repeat for each line tSubStack in the substacks of this stack close stack tSubStack end repeat end closeStack X cREVGeneral scriptChecksum f*z.!+] bookmarks handlerList closeStackscriptSelection char 104 to 103prevHandler preOpenCardtempScript scripton closeStack
repeat for each line tSubStack in the substacks of this stack
close stack tSubStack
end repeat
end closeStack
@ BlackCheckmark.png PNG IHDR pHYs gAMA |Q cHRM z% u0 ` : o_F xIDATxb` 17 R@L:̤/@,0@ 1I +x%@ Lħ HW ť $@PIV dĊK8 0 6 IENDB` cREVGeneral revUniqueID 1109347801497 SB i - F cREVGeneral revUniqueID 1109350058804 Info ` cREVGeneral revUniqueID 1109350253372 #How-To stack #013 by Eric Chatonet " 4/11/05 Initial release 45/27/05 Modified for Tutorial Picker compatibility @ @ , /This stack shows how to manage tabbed buttons. . :A tab panel is a menu button the items of which are tabs. lTo display different bushes of controls when the user selects a tab, you have the choice between 2 methods: C------------------------------------------------------------------ - Multiple cards method (each tab is a card) @ 1600 @ Each bush of controls you need for each tab is placed on a specific card and the tabbed buton is placed as a group at the lower level with its background behavior set to true on all these cards. -Each click on a tab goes to a specific card. @ , .1. Create a tabbed button at the lower level. $ HIn the tools palette, tabbed button tool is the last in the second row. G G {2. Display the property palette about this tabbed button and type the names of yours tabs in the text area (one per line). p 83. Group the tabbed button (Group icon in the toolbar). ! s4. Display the property palette about this new group and check its background behaviour at the bottom of the pane. 9 C W 5. Create as many new cards as tabs you want to use (if the cards already exist, display each of them and choose Place group in the Objects menu). h q | 16.Name these cards exactly as your needed tabs. ) @7. Write a menuPick handler in the script of the tabbed button: , on menuPick pNewItem,pOldItem @ brown @ @ black go card pNewItem @ blue @ F -- assuming that the names of the cards are the names of the tabs @ hh"" DarkOrchid4 ( @ hh"" DarkOrchid4 , @ hh"" DarkOrchid4 / end menuPick @ BpNewItem parameter contains the name of the tab the user clicked. 9 BpOldItem parameter contains the name of the current selected tab. 9 If the method which consists in naming the cards exactly as you named the tabs is handy, any valid description can be used to specify the right card in the menuPick handler. For instance: " go card (the menuHistory of me) @ blue @ @ black @ @ red @ darkorange @ black @ -- assuming that you use the first cards 1 to x of your stack @ black @ hh"" DarkOrchid4 = -- to display 1 to x tabs @ hh"" DarkOrchid4 C8. Add the needed controls for each tab in the corresponding card. %See the script in the example stack. $ 5See below for extra scripting tips for both methods. 4 C------------------------------------------------------------------ : Groups method (show/hide groups based on tab selection) @ 1600 @ ' +This second method requires a single card. [All controls corresponding to a tab are grouped: there are as many groups as you want tabs OWhen the user chooses a tab, you show the corresponding group and hide others. .1. Create a tabbed button at the lower level. $ HIn the tools palette, tabbed button tool is the last in the second row. G G {2. Display the property palette about this tabbed button and type the names of yours tabs in the text area (one per line). p @3. Create the controls needed by your first tab and group them. + 4 9 74.Name this group exactly as you named the first tab. / .5. Repeat this procedure for all needed tabs. $ @6. Write a menuPick handler in the script of the tabbed button: , on menuPick pNewItem,pOldItem @ blue @ brown @ @ black . lock screen -- ensures a clean transition @ blue @ black @ blue @ hh"" DarkOrchid4 1 hide group pOldItem -- current visible group @ blue @ blue @ blue @ hh"" DarkOrchid4 ( show group pNewItem -- clicked tab @ blue @ blue @ blue @ hh"" DarkOrchid4 unlock screen @ blue @ blue G -- assuming that the names of the groups are the names of the tabs @ blue @ hh"" DarkOrchid4 ) @ hh"" DarkOrchid4 - @ hh"" DarkOrchid4 0 end menuPick @ blue @ BpNewItem parameter contains the name of the tab the user clicked. 9 BpOldItem parameter contains the name of the current selected tab. 9 .You might prefer a more reliable formulation: on menuPick pNewItem,pOldItem @ blue @ brown @ @ black lock screen @ blue @ black @ blue 3 repeat for each line tGroup in button "MyTabs" @ blue @ brown # < hide group tGroup -- hide all groups to avoid garbage @ blue @ blue @ blue @ hh"" DarkOrchid4 # end repeat @ blue @ brown @ brown show group pNewItem @ blue @ blue @ blue unlock screen @ blue @ blue end menuPick @ blue @ brown %See the script in the example stack. $ 5See below for extra scripting tips for both methods. 4 C------------------------------------------------------------------ Shared tips & How to set the tabs names by script @ 1600 # 8Tabs names are the text of the button, a name per line. @ black 7 FYou can set this text manually in the propoerty palette or by script: @ black E @ black ? put "Tab1" & cr & "Tab2" into button "MyTabs" -- text values @ blue + @ hh"" DarkOrchid4 0 H put line 1 to 2 of the windows into button "MyTabs" -- property value @ blue @ darkorange @ hh"" DarkOrchid4 6 B put tVar1 & cr & tVar2 into button "MyTabs" -- variables values @ hh"" DarkOrchid4 @ blue ) @ hh"" DarkOrchid4 . @ black How to select a tab by script @ 1600 3 set the menuHistory of button "MyTabs" to number @ blue @ red @ black , @ black 8Where number is an integer according to the tabs order. @ black @ black @ black * When you set the menuHistory property of a menu button, the engine sends a menuPick message to this button and your code is executed. @ black @ black @ black / @ black K @ black S 2 nThat is the way to select the right tab in a preOpenStack handler (initialization) or simulate an user click. @ black m @ black ANote that number can emerge from any eavluation as for instance: @ black @ black @ black 0 @ black $ lineOffset(tTabname,btn "MyTabs") @ darkorange @ black @ black @ black + How to disable or enable a tab by script @ 1600 ( @ black jTo disable or enable a tab, just add or remove a parenthesis placed before its name in the button's text: @ black i @ black 5 if char 1 of line 2 of button "MyTabs" <> "(" then @ brown , @ brown 0 : put "(" before line 2 of button "MyTabs" -- disable @ blue & @ hh"" DarkOrchid4 / end if @ brown @ brown @ black 4 if char 1 of line 2 of button "MyTabs" = "(" then @ brown + @ brown / ; delete char 1 of line 2 of button "MyTabs" -- enable @ blue $ @ hh"" DarkOrchid4 1 end if @ brown @ brown C------------------------------------------------------------------ " Which topics check in the docs? @ 1600 Button object Tabbed keyword MenuMode property MenuHistory property MenuPick message @How do I respond to the user clicking a tab in a tabbed window? $faq/ng_a_tab_in_a_tabbed_window.xml ? %How do I switch between button tabs? $faq/_switch_between_button_tabs.xml $ C------------------------------------------------------------------ Which method choose? @ 1600 ZMultiple cards method makes tabbed buttons management easier but requires multiple cards. In complex projects, it appears often preferable to restrict the number of cards as much as possible: that is the case with the groups method. The groups method lets you display more than one group together when working: it is often handy in order to align objects and get a satisfactory layout. DBoth methods work perfectly: the best one is the one you prefer :-) @ black ` SSS.png Hon mouseDown revGoUrl "http://www.sosmartsoftware.com" end mouseDown . " -PNG IHDR " . pHYs .# .#x?v 9iCCPPhotoshop ICC profile xڝwTTϽwz0z.0. Qf Ml@DEHb!(`HPb0dFJ|yyǽgs{. $O./ 'z8WGб x 0Y驾A@$/7z HeOOҬT _lN:K"N3"$F/JPrb[䥟}Qd[Sl1x{#bG\NoX3I[ql2 $8xtr p/8pCfq.Knjm͠{r28?.)ɩL^6 g,qm"[Z[Z~Q7%" 3R `̊j[~ : w! $E}kyhyRm333: }=#vʉe tqX)I)B>== <8Xȉ9