cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
shampton82
Level VII

Script to make a toolbar button to turn on and off graph builder fit to window

Hey everyone,

I was wondering if someone could help me out with a script that I could assign to my toolbar so that I could "one click" turn graph builders "Fit to Window" options on and off

shampton82_0-1713462516528.png

 

So if it I clicked it and the current selection was "Auto/On/MAR" then it would set Fit to Window to "Off" and if the current section was "Off" then it would set Fit to Window to "On".

 

Thanks for any input on how to do this!

 

Steve

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Script to make a toolbar button to turn on and off graph builder fit to window

I'm not sure if there is any direct message to get the current Fit To Window setting, but something like this might work

Names Default To Here(1);

gb_ref = (Current Report() << XPath("//OutlineBox[@helpKey = 'Graph Builder']"))[1] << Get Scriptable Object;
cur_stretch = All(gb_ref << Get Auto Stretching);
If(cur_stretch,
	gb_ref << Fit to Window("Off")
,
	gb_ref << Fit to Window("On")
);
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Script to make a toolbar button to turn on and off graph builder fit to window

I'm not sure if there is any direct message to get the current Fit To Window setting, but something like this might work

Names Default To Here(1);

gb_ref = (Current Report() << XPath("//OutlineBox[@helpKey = 'Graph Builder']"))[1] << Get Scriptable Object;
cur_stretch = All(gb_ref << Get Auto Stretching);
If(cur_stretch,
	gb_ref << Fit to Window("Off")
,
	gb_ref << Fit to Window("On")
);
-Jarmo
shampton82
Level VII

Re: Script to make a toolbar button to turn on and off graph builder fit to window

Looks like that worked!  Thanks a ton.

 

One last little ask, what would need to be added to the current state to the subtitle?  So something like this? 

shampton82_0-1713465581907.png

 

jthi
Super User

Re: Script to make a toolbar button to turn on and off graph builder fit to window

Not sure if it has any specific message either, but you can try to find the text edit box (this isn't the most robust option but should work in simple cases)

 

Names Default To Here(1); 

gb_ref = (Current Report() << XPath("//OutlineBox[@helpKey = 'Graph Builder']"))[1] << Get Scriptable Object;
cur_stretch = All(gb_ref << Get Auto Stretching);

fit_state = If(cur_stretch, "Off", "On");
gb_ref << Fit to Window(fit_state);
Report(gb_ref)[GraphBuilderTitleBox(2), TextEditBox(1)] << Set Text(Eval Insert("FTW = ^fit_state^"));

If you want to make sure that the subtitle is visible you can add

gb_ref << Show Subtitle(1); 

to end

 

-Jarmo
shampton82
Level VII

Re: Script to make a toolbar button to turn on and off graph builder fit to window

You rock Jarmo, thanks for all the great help (as usual)!

Steve