Tipswip   >   Windows   >   Tab Panes

Tab Panes

TAB PANES

This section covers various topics related to tab panes.

I especially like using tab panes with subwindows. See Tab Pane Subwindows for more information.

$alltabcaptions, $alltabtooltips

If you use the F4 Notation Inspector and click the magnifying glass on a tab pane object in design mode, then press the F6 Property Inspector and look under the General tab you will see the properties $alltabcaptions and $alltabtooltips.

Hovering over these properties with the mouse the tooltip explains that these properties return all a carriage return separated string of the tab captions or tooltips.

When I discovered this property I thought, "Great! We can assign the tabs caption without needing to lobject-oriented programming through the tab panes". Unfortunately $alltabcaptions and $alltabtooltips are not assignable and they are class properties and not class instance properties.

In my opinion, this renders these properties useless to the developer.

Click the "Run Demo" button for a demonstration.

Thanks to Philippe Sarfati for raising the $alltabcaptions question.

Dynamic Tab Pane Captions

Rather than set the tab pane captions manually, you can set them dynamically.

The tab pane in the StudioTips Browser window is set dynamically using notation.

This is accomplished by looping through a list which contains the tab pane captions. As you lobject-oriented programming through the list you need to set the $currenttab and then assign the $panecaption and other pane specific properties which you want to set.

The sample code below and demo show how to dynamically set the tab captions. Thinking in object-oriented terms, the method is named $setTabPaneCaptions and is added to the tab pane object. You then "send" a "$setTabPaneCaptions" message to the tab pane object passing the list of the tab pane captions as a parameter. To access this method from outside of the window class you would add a $setTabPaneCaptions window class method and redirect the call to the tab pane.

NOTE: Each time you set $currenttab an evTabSelected event is generated (if it results in changing the current tab). If you have code that runs when you change the current tab, you will want to temporarily stop the tab events from being generated while the tab pane captions are being set. A good trick is to temporarily set the tab pane object $active property to kFalse while setting the tab captions. Thanks to Brian O'Sullivan for this tip!

Tab Pane Subwindows

I especialy like using tab panes with subwindows.

Tab1 might be the purchase order header and tab2 would be the purchase order items.

To improve window instantiation time, the $classname property of tab2,3,... is not assigned until the user clicks on the respective tab. This way when the window is intantiated only tab1's subwindow is instantiated.

The sample code and demo show you how this can be accomplished.

NOTE: If you wanted to create a flexible tab pane object you could have the tab pane add the subwindow field to itself using notation. You could create an instance variable list, iTabPaneList, which stores the tab caption names and the class name of each subwindow or an item reference to it. Then create a method, $addTabPaneSubWin(pTabNum,pTabCaption,prWin), which adds a new line to the iTabPanesList... and you've got yourself a very flexible reuseable object-oriented tab pane window which could be instantiated again and again.