Set size of global variable widget

Hello. I’ve been using Axure RP for a few months and keep getting stuck on the same problem.
I want to have a set a property of a widget which is stored as a global variable.
A typical example - I have a load of widgets and when clicked, they should change size. And when I click somewhere else, it should set the widget back to its original size.
So I can add a global variable clicked_widget is this widget [[LVAR1]]
then I set its size to big in the same case.

Now when I click on a button I need to be able to set the size of clicked_widget back to a smaller size.

I really can’t work out how to do this. It’s been bugging me for ages.

In general, you could have two global variables, one for the “big” size and/or scaling factor, and one to use as a temporary buffer, holding the size of the clicked widget before it gets changed to the big size.

See this example:
https://uijtfr.axshare.com

Widget Resizing.rp (95.6 KB)

I set all sample widgets to the same Selection Group (“my widgets”) so that only one could be selected and big. When a widget is clicked, it selects itself, and the OnSelected event first stores its current size (width and height) to the global variable, ClickedWidgetSize. Then it resizes itself using the scaling factor stored in the global variable, BigSize (which is initiated to default value of “2” in the Project: Global Variables settings.). For demonstration purposes, it sets the text of the “clickResults” widget to show its original size and new size. When the widget is unselected, it resizes itself using the ClickedWidgetSize value.

To use just one global variable for size, which is defined by a (width, height) pair, I had to do some fancy parsing, using the string.substr() function. It might be easier and more straightforward to use two temp variables, like ClickedWidgetWidth and ClickedWidgetHeight.

I included a “Reset Widget” button to demonstrate that functionality. For good measure, I added an OnClick action to the page, so clicking anywhere on the background would trigger the same reset action.

2 Likes

That’s for that.
I had never thought of using selection states and selection groups to tackle this.
That helped.
Cheers.