Is there a way to make different buttons in a Button Bar the active segment depending on the slide number/slide object name on a layout? I have a layout where 5 of 6 of the buttons on the Button Bar just jump to a different slide on the same layout.
1: Specify a name for each of your panel, say Panel1, Panel2 etc
2: Specify a name for each button in the button bar, say Button1, Button2 etc
3: Choose calculation for the active button setting and specify something like:
GetLayoutObjectAttribute ( "Panel1" ; "isFrontPanel" ) ; "Button1" ;
GetLayoutObjectAttribute ( "Panel2" ; "isFrontPanel" ) ; "Button2" ;
You might need to name the button bar as a whole and use a Refresh object step for the whole button bar in any script that can bring another panel to the front without using the related button.
You could simplify that a lot with a script that updates a global variable with the name or number of the panel that moves to the front. The script can be performed by the OnPanelSwitch trigger. There's a get function that will tell you the object name and number of the panel that will be the front panel once the panel switch event has been processed.
So I understand: "Panel1" is replaced with first slide name; "isFrontPanel" stays and is code for active segment; "Button1" is replaced with the button name?
True, I'm actually aware of the trigger and the get function it just didn't come to my mind. Your way is actually better since many actions even Go to Field or Go to Object could trigger the panel switch meaning an OnPanelSwitch triggered script would be required anyway.
Either way, the Refresh Object is required to change the active button unless it was clicked directly.
Yes, isFrontPanel returns 1 if the panel tested for is the one in front. However, the second method described by Phil is better.
If I use the:
technique, does the last one have a ";" or no ";"? [seems to be working with an ending ";" but would like to do it right.]
Also, trying it and two of the buttons in the button bar are drop-downs and when clicked, the slides opened in the drop-down buttons do not show the active button like the others.
arjen seems to agree with you, phil, to use a global variable. How exactly do I set that up? I understand to create a gButtonSelect (or the like), but how exactly to I set the global variable to be the front button and how do I use the get function in the trigger script?
A case statement is basically a list with ifs and after the last one you can add a default result. Your stat can have a default result or not, but the end has no ;.
if ; then ;
elseif ; then ;
The case statement stops evaluating a soon as something tests true or the end is reached.
Here's the alternative in more detail:
Use OnPanelSwitch to perform this script:
Set Variable [$$FrontPanelName ; Value: GetValue ( Get ( TriggerTargetPanel ) ; 2 ) ]
Refresh Object ["ButtonBarName"]
You might need to name each button and refresh them all here if refreshing the whole buttonbar doesn't work.
But even then, what you have is much simpler no?
The most simple would be to name the buttons the same as the panels. Then the calc for the active button would be simply $$FrontPanelName. You calc would need more logic to account for the button that is not connected to a panel (you mentioned 5 of 6 buttons are related to panels?) depending on what that last button does.
$$FrontPanelName is my global variable, yes? I'm trying to follow and I think I'm missing something. How does this identify the specific slide and then identify which specific button to bring to the front? I'm not super familiar with "Value: GetValue ( Get ( TriggerTargetPanel ) ; 2 )". Will research, but in case it is something simple that I'm missing.
ezeitgeist wrote: Also, trying it and two of the buttons in the button bar are drop-downs and when clicked, the slides opened in the drop-down buttons do not show the active button like the others.
Sorry, I missed this part of your reply. With drop-down do you mean Popover?
In a button bar buttons with popover are active as long as the popover is open. How do you want it to work? Any chance to share a screenshot of your interface?
Let's summarize assuming your panels are named Panel1, Panel2, Panel3, etc, your buttons in the button bar are named Button1, Button2, Button3 and the buttonbar as a whole ButtonBar1. You can ofcourse replace this with any names you want.
A script assigned to the script trigger OnPanelSwitch will run any time the slide control changes to a different slide. Script triggered with by this trigger can use Get(TriggerTargetPanel) which will return two values, the first being the index number, the second being the object name of the slide that is going to become the front slide.
In the script the global variable is set by GetValue ( Get ( TriggerTargetPanel ) ; 2 ) which means the second value of the result of Get (TriggerTargetPanel) meaning the object name of the slide that is going to be the front slide.
After the global variable is set we refresh the buttonbar to re-evaluate the active button calculation since the global variable on which this calculation is based has been or might have been changed.
In the calculation for the active button in your button bar you have a case statement checking the global variable and make use the button name as the result.
Forget my previous reply about naming the buttons the same as the panels, you can't have the same object name twice on the same lay-out.
You could still specify the calculation for the active button as a simply your global variable in case you would use the button names as 1, 2, 3 etc and change the script step to set the global variable to GetValue ( Get ( TriggerTargetPanel ) ; 1 ). In that case you get the first value of the Get(TriggerTargetPanel) result which is the index number of the slide instead of the name.
The top "Motivation" through "Help" is the button bar. "Connection &" and "Help &" are PopOver buttons that I have added buttons within those popovers that are navigation buttons as well.
In this case, all 3 buttons under "Connection &" bring you to different slides in that same layout (as do the non-PopOver buttons in the bar). I'd like on all three of those slides to have "Connection &" button bar button active.
I tried with arjen's approach and works for all PopOver buttons EXCEPT the first one down (top most). "Help &" PopOver has two buttons in the PopOver, the bottom one is to a different layout, the top one to a slide in the original layout. The top button, again, does not set "Help &" active when clicked.
Ok, now we are getting close. Keep using Phil's suggestion to get the name of the panel in a global variable and make your calculation for the active button:
$$FrontPanelName = "Motion" ; "Button1" ;
$$FrontPanelName = "Networking" ; "Button2" ;
$$FrontPanelName = "ConnectionLogging" ; "Button3" ;
$$FrontPanelName = "CastingSessions" ; "Button3" ;
$$FrontPanelName = "CastingSessionsLog" ; "Button3" ;
$$FrontPanelName = "BusinessSide" ; "Button4" ;
$$FrontPanelName = "Help1" ; "Button5" ;
$$FrontPanelName = "Help2" ; "Button5
The panel and button names are up to you, but I guess you get the idea.
I think to simplify, assuming this is working I would use a simpler naming convention. If the panels were named:
motion_slide, network_slide, etc. and the corresponding buttons:
motion_button, network_button, etc.
Then instead of this:
Then something like:
Set Variable [$$ActiveButton;LeftWords($$FrontPanelName;1) & "_button"]
If one slide would connect to one button I would do the same, but the case here is using some buttons connected to one slide and some buttons connected to multiple slides and then this won't work.
There are still ways to shorten the code but I don't think it would get simpler.
Retrieving data ...