Figured it out...
- Add a new field to your table - it will be a temp field used to set the name of the segment you want active
- Go into Active Segment in the Button Bar, Click Specify. In the calculation select the temp field you just created
- Make sure all of the segments have a name
- Set the name of one of the segments to the temp field & commit
- The segments active state changes to what you specified in the temp field
Hide the field off to the right out of your layout and then set the Active segment name as needed in your Nav scripts
Doesn't sound like a solution that would work under all circumstances, what if a different user is on the same record but on a different segments and wants his to change state?
- you might get a record locked conflict with other users
- other user's buttom bar segment will change state without them doing anything
As a rule you would want to avoid modifying a record just to make some UI widget work...
Global fields could work in this scenario.
I agree, just came to that conclusion as well. Thanks much!!
Had the same issue, and tried this solution Jesse recommended, but using a global var as Win suggested.
- Set the Active Segment calculation to "$$ACTIVE.SEGMENT.NAME"
- All segments have a name (that is, an object name specified within inspector, not to be confused with the button title that user sees specified within the button bar popup)
- Set $$ACTIVE.SEGMENT.NAME to the object name of the segment I wanted.
Works like a charm for each record transition (e.g. using next/previous commands).
I do this in a few solutions. Have an onLayoutEnter script trigger set a global variable $$PanelNumber to 1, as the first slide panel is the default when you enter a layout and then have a calculation on the button bar to specify active state, something like:
$$PanelNumber = 1; "buttonbar.1";
$$PanelNumber = 2; "buttonbar.2";
$$PanelNumber = 3; "buttonbar.3";
$$PanelNumber = 4; "buttonbar.4";
$$PanelNumber = 5; "buttonbar.5"
then have an OnPanel switch script trigger on the slide panel with that sets $$PanelNumber to GetValue( Get ( TriggerTargetPanel) ; 1)
Seems to work fine, without having to set a field
Well, all this works within one file. But there is a problem for me switching layouts between different files.
But I have two separate files. I switch from one file to the other with a script that leads the user to the respective layout. Here the button bar is confused.
I am setting the global variable $$activeSegment to the object name of the button bar segment.
This all works fine in one file.
But when moving from one file to the other, even with an onLayoutOpen trigger setting the global variable $$activeSegment (in the new file), the active state is showing the state from the file from where the user left.
After a lot of testing, I found that for this thing to work in separate files, it is also necessary to have a last "refresh window" stop. This finally worked.
So, in my case, a simple button bar in two different files:
- Define object names for each segment button
- Set the active segment of the button bar to the global variable $$activeSegment
- Use the "onLayoutEnter" trigger of the layout to the script which sets the global variable to the segment buttons object name.
- Refresh the screen (important!)
IIn my case, the segment buttons have the current layout name, so I simply call for get(layoutname) and set the global to the layoutName which is the same as the segment button object name.
(There are more dynamic button bars of course, but here I just came across the problem switching to layouts in other files)