Set Compound widget visibilty from within itself

Hey,
I am trying to hide and show a compound widget from within itself, triggered by the change of a bound variable.
This is some example code of what I would like to achieve, but it doesn’t work in the current form:

<EventBinding id="VarChange">
	<Source xsi:type="this.Event" event="SelectedBlockChanged" />
	<EventHandler condition="value &lt;&gt; 0">
		<Action>
			<Target xsi:type="this.Action">
				<Method name="SetVisible" value="false" />
			</Target>
		</Action>
	</EventHandler>
	<EventHandler condition="value = 0">
		<Action>
			<Target xsi:type="this.Action">
				<Method name="SetVisible" value="true" />
			</Target>
		</Action>
	</EventHandler>
</EventBinding>

I know it would be possible to publish the event and react to it outside the compound widget but I’d prefer an encapsulated solution.

Thanks
Tim

1 Like

Hello Tim Göhringer,

When using an event binding, no opcUa, session and clients system events are permitted, only events that comes with the widgets, so directly it wouldn’t be possible.

One workaround I did in the past, was to use and invisible widget (one that can bond with an numeric value), and detect when value changes and then set the overall visiblity based on the output of the said invisible widget.

Regards

Sorry, I forgot to mention. I am binding one local Property to an OPC UA Variable and react to the change of the local property.

One more thing, would it alternatively be possible to bind the Compound widget visibility to a local property/hidden Input?

Hello,

I took a look at help regarding the local properties , and it seems that the event ValueChanged of local properties can be responded in the event binding of the compound widget. For more information, the link above is set the help page regarding that,

Yes, that’s what I am doing currently. The Event is not the problem, setting the Compound widget visibility in that event is.

Hi Tim,

I don’t know whether it is possible to set the entire CompoundWidget invisible inside itself.

You could put all widgets of CompoundWidget in a GroupBox and set it invisible or change style of Widgets.
But place in content will be always be reserved for pseudo invisble CompoundWidget. :confused:

Thanks for your answer. Sadly I have to control the visibility of all Compound widgets indivually, so I cant group them.
But one thing I found, if you put the compound widgets inside of a FlexLayoutPanel no gaps are existant when making Widgets invisible.

What I meant, was to put all widgets inside the CompoundWidget in a GroupBox.

Really interesting thing about the FlexLayoutPanel…

Ah ok, now I understood. In this case your point with the reserved space stands, because the widget didnt really changed for the overlying MappView Content.

1 Like

After a bit of further experimenting and talks with B&R Support I managend to find what I was looking for.
Although (I think) not documented anywhere, it is possible to access the local property visible and probably others the same way you can access self created local properties.

This means you can hide the entire compound widget from within itself, just like from outside, with this action:

<EventBinding id="HideWidget">
	<Source xsi:type="widget.Event" widgetRefId="Btn_HideWidget" event="Click" />
	<EventHandler condition="">
		<Action>
			<Target xsi:type="this.Action">
				<Method name="SetVisible" value="false" />
			</Target>
		</Action>
	</EventHandler>
</EventBinding>

5 Likes