If you are using FileMaker 12 or newer, the OnPanelSwitch trigger (name is different in v12) can perform a script. In that script, Get ( TriggerTargetPanel ) returns both the object name and the index (return separated list) of the newly front most target panel.
Please note that the front panel of a tab control may not actually be "active" as an "active" layout object has the current focus via pressing a key on the keyboard (such as tab) to change that focus. (Mouse clicks may or may not change the focus depending on the object clicked. A clicked button, for example, does not become the active layout object.)
1 of 1 people found this helpful
You can test whether predefined tabs are the frontmost or not using GetLayoutObjectAttribute ( tabName ; "isFrontPanel" ).
The Get(TriggerTargetPanel)'s help says: "Use with the Get(TriggerCurrentPanel) function. Returns an index value, starting from 1, when running a script triggered by the OnPanelSwitch script trigger..."
My situation is that I have a button on top of the tab display that I only want to have, in this case, create a new record, for certain tabs.
Putting the GET(TriggerTargetPanel) in the "ADD RECORD" script always returns 0.
Some object orientation would be super helpful here. Using the tab object name, there should be a function that returns data about that tab (tabObjectName.getActiveTabName(), ....).
What am I missing?
P.S. I also tried the GetLayoutObjectAttribute ( tabName ; "isFrontPanel" ) as David above suggested, but that also returns 0 on each tab.
I recommended get ( TriggerTARGETpanel ) not the current panel version. Both of these get functions return both the index and the object name of the panel (if you use the inspector) to give the object names to your panels and both require using the OnPanelSwitch trigger to perform a script first.
David's method seems much more straight forward, but object names have to be specifically assigned via the Name box in the inspector. These are not the labels you might assign via tab control set up.
My button is not part of the tab control so it always displays zero.
I'll try to use the OnPanelSwitch trigger to set a global variable that I can check fro the button outside the tab control.
Seems like that's my best bet.
Appreciate the help.
Actually, I think David had the better idea...
Perhaps I am confused in some way, but, from a button being used OUTSIDE the tab control, neither approach described above worked. They both always produced a zero (in get ( TriggerTARGETpanel )) regardless of the tab.
I have a toolbar outside the tab control where some buttons should work only on some tabs. In FMP, unfortunately, there is still no way that I know of to do the utterly basic thing, available in every other development environment I know of, of "graying out and disabling" a button using a logical condition. Perhaps in FMP 17? ;)
What I did get working was in the tab change event, I updated a global variable with the get ( TriggerTARGETpanel. Then, in the command button, which, again, is outside the tab control, I can see the correct tab panel chosen. I had to initialize the global variable to the default tab up front. This was much more of a cludge than should have been necessary.
With a more object oriented design (tabObject.method(), for example), this type of problem would be simple to work with. No global variables, etc.. And, I would argue would be even simpler.
However, FMP continues to amaze me with just how fast I can put something together that's usable. :)
You don't need global variables or triggers. You just need to understand the tools FileMaker has.
Read the help file on GetLayoutObjectAttribute(). You'll need that to identify the frontmost tab panel.
While there isn't a super simple way to grey and disable a button, you can hide button using the "Hide object when..." option. You can also grey a button using conditional formatting and disable it by putting an Exit() condition early in the script.
I think I took your example above literally ("isfrontTab").
This is still more difficult that it should be since even a non-object oriented "GET(ActiveTabName)" would be simple, easy to understand, and use.
Thanks again. :)
I'm sure you found a good way to do this, but for the benefit of any others, I had a similar challenge of wanting to be able to return to the Tab I was on at the completion of a script.
I did it by setting a global variable like this:
Set Variable [$$ReturnToObject ; Value: GetValue (Get(TriggerTargetPanel);2)
Value 2 gives me the name of the panel (you have to name them first of course), then at the end of the script its a simple
Go to Object $$ReturnToObject
Hope it helps someone
Thanks Nick, your solution was exactly what I needed!