Copy link to clipboard
Copied
Friends an experts,
The problem is related to the ScriptUI implementation. There seems to be a difference between the ID implementation and the FM implementation.
I have a window wPalM with 3 tabs in the tabbed panel tp:
wPalM.tp.tAny
wPalM.tp.tIndx
wPalM.tp.tIndxV
In each of these tabs there is an edit field and other controls.
When pressing a button on the top level (wPalM) i want to know on which edit-field I will operate (wPalM...eMarkerContens).
In the famous “SriptUI for Dummies” Peter Kahrel suggests to use tpanel.selection = 1 for the second tab. But I can not find that this property is a numeric index. It is [object panel].
I can not find how to know the currently active tab. Neither .visible, nor .active is helpful. The only useful information is in wPalM.tp.selection.text - but this depends on the language of the interface and is really clumsy:
if (wPalM.tp.selection.text == KLD_M.UItxt.wPalM.@tptAnytitle.toString() ) { ...}
if (wPalM.tp.selection.text == KLD_M.UItxt.wPalM.@tptIndxtitle.toString() ) { ...}
if (wPalM.tp.selection.text == KLD_M.UItxt.wPalM.@tptIndxVtitle.toString() ) { ...}
(UItxt is an XML structure which is switched between UI languages along these lines:
<wPalM tptAnytitle = "Any marker" />
<wPalM tptIndxtitle = "Index marker" />
<wPalM tptIndxVtitle = "Template marker" />
I’m looking for a solution with an index!
Hello Klaus my friend,
If you do not have an index, then make one for yourself:
var gDlg = new Window("dialog","TEST",undefined,{resizeable:false,maximizeButton:false});
var TabbedPanel = gDlg.add("tabbedpanel");
var Tab1 = TabbedPanel.add("tab",undefined,"Tab0",{index:0});
var Tab2 = TabbedPanel.add("tab",undefined,"Tab1",{index:1});
var Tab3 = TabbedPanel.add("tab",undefined,"Tab2",{index:2});
var ShowButton = gDlg.add("button",undefi
...
Copy link to clipboard
Copied
Well, I have found a solution ...
var jTab = KLD_M.ActiveTab(wPalM.tp);
if (jTab == 0) {wPalM.tp.tAny.g1.p2.eMark.textselection = KLD_M.sMarkerText;}
if (jTab == 1) {wPalM.tp.tIndx.g0.eMark1.textselection = KLD_M.sMarkerText;}
if (jTab == 2) {wPalM.tp.tIndxV.g0.eMark2.textselection = KLD_M.sMarkerText;}
KLD_M.ActiveTab = function (oTabbedPanel) { // =======================================
/* Determine the index of the active tab within a tabbed panel
Arguments oTabbedPanel The object in question
Return Index of active tab (0 … n) or null in case of error
Comment While in the Indesign implementation of ScriptUI there seems to be such an
index, the FM implementation does not provide it.
History 2021-09-24
*/
var j, nTabs, oChild;
nTabs = oTabbedPanel.children.length;
for ( j= 0; nTabs; j++) {
oChild = oTabbedPanel.children[j];
if (oTabbedPanel.selection.text == oChild.text) {
return j;
}
}
return null;
} //--- end ActiveTab ----------------------------------------------------------------
Copy link to clipboard
Copied
Hello Klaus my friend,
If you do not have an index, then make one for yourself:
var gDlg = new Window("dialog","TEST",undefined,{resizeable:false,maximizeButton:false});
var TabbedPanel = gDlg.add("tabbedpanel");
var Tab1 = TabbedPanel.add("tab",undefined,"Tab0",{index:0});
var Tab2 = TabbedPanel.add("tab",undefined,"Tab1",{index:1});
var Tab3 = TabbedPanel.add("tab",undefined,"Tab2",{index:2});
var ShowButton = gDlg.add("button",undefined,"ShowActivTabIndex");
ShowButton.onClick = ShowActiveTab;
gDlg.show();
function ShowActiveTab()
{
var ActivTabIndex = TabbedPanel.selection.properties.index;
alert ("Index: " + ActivTabIndex);
alert(TabbedPanel.children[ActivTabIndex].text);
}
You can assign any property to any object in GUI using {}: {index:0}
You can choose any name you want.
Just test the above snippet.
Copy link to clipboard
Copied
Klaus, what an enlightment!
I must confess, this is the real answer, not mine ...
Edit
«You can choose any name you want.» is IMHO based on the fact that both Tabbed Panel and Tab do not have any creation properties - at least I have not found such in the User Guide etc.