Omnis Technical Note TNNO0012
Moving objects on a specific tab of a tab pane
For Omnis Studio
By Omnis Technical Support
This technical note describes how to move objects
from one pane to another easily.
When adding new tab panes one is always faced with the problem of how
to move the objects in a pane from one pane to another. What happens if
one wants to add a new first pane to the tab pane? Incrementing $tabcount
will add a new pane to the END of the tab pane window object. How then
one move the objects in pane x to pane x+1 for all the panes. Studio versions
of 2.1 and later offer the $pagenumber method\property. This notation
allows one to find out which pane a window object in a tab pane is in
as well as set the pane number for that object. The code below will move
the objects from a pane (OldPane) to a pane (NewPane) where 'OldPane'
and 'NewPane are pane numbers and the tab pane has the $name 'TP'.
#####Method '$event'#####
No. Local Variable Type Subtype
1. Count Long integer
2. num Short intger (0 to 255)
3. ObjRef Item reference
4. PaneObjList List
5. TabPaneRef Item reference
No. Method text
1 On evClick
2 If OldPane>0&NewPane>0
3 Set reference TabPaneRef to $cinst.$objs.TP
4 Do TabPaneRef.$objs.$makelist($ref.$name,$ref) Returns PaneObjList
5 Calculate count as PaneObjList.$linecount
6 For num from 1 to count step 1
7 Set reference ObjRef to PaneObjList[num].C2
8 Calculate PaneObjList[num].C1 as TabPaneRef.$panenumber(ObjRef)
9 If PaneObjList.[num].C1=OldPane
10 Do TabPaneRef.$panenumber(ObjRef,NewPane) Returns #F
11 End If
12 End For
13 End If
Notes on the above code:
1. One can refer to a column of a list in Studio by referencing the column
with C1, C2 etc irrespective
of the name of the column, so 'ListA.2.C6' will
refer to the cell of a list called 'ListA' in the second
row and in the sixth column.
2. In line 4 $makelist is used to make a list of the objects on all the
panes of the tab pane and, as a
second column, store an item reference to each
object.
3. Comparing line 8 and line 10, notice that $panenumber can be used to
assign a pane number of an
object as well as read the pane number of an object.
Also, $panenumber is a method of the
tab pane, not of the object in the tabpane. Depending
on the parameters passed to the method,
the method will get or set the pane number of
an object.
4. In line 4 a variable is used to store the $linecount of the pane object
list. One could have placed the
notation 'PaneObjList.$linecount' in line 6 i.e.
directly in the For...' loop, but then the notation would
have been re-evaluated for each loop. Populating
a variable with the $linecount and using that
variable in the loop makes the loop slightly faster.
Download a sample library from GitHub: https://github.com/OmnisStudio/Omnis-MovePanes (for Studio 8.1.2 or above)
(or an archive: movepane.zip for Studio 4 or above, may require conversion)