Hiding Objects On Condition

I’m almost certain this has been asked before, but I can’t seem to find a good resolution through the search feature, so I am posing this.

I have been doing the tutorials online the past week and the youtube videos and there’s a feature from Archestra that I’m tying to mimic in Ignition.

How exactly do I go about hiding an object? For Instance, if I have two WriteableBooleans and both are their own button, how can I hide one if the other is enabled?

For instance, if WriteableBoolean1 is TRUE, I want the button for WriteableBoolean2 to not be visible.

Thanks for your help, in advance.

2 Likes

The short answer is that every component has a visible property. All you have to do is use a binding or write an expression or script that sets the visible property of a component to False or 0.

That’s what I’m trying to do with this code that exists on WriteBoolean2’s button, and the script is for PropertyChange.

x = system.tag.read (‘Alarms/WriteableBoolean1’)
if x.value is True:
event.source.visible = False
else:
event.source.visible = True

Unless I’m completely wrong on how the event.source is working, (I used the expression browser to make sure I chose the visibility tag for the button I’m trying to hide) I’m missing something. When I click the button for WB1, the visibility expression never changes.

Your problem here is that no property changes when clicking a button so this script never runs.

On the button, put the script in the “actionPerformed” event handler.

Nick

[quote=“nmudge”]Your problem here is that no property changes when clicking a button so this script never runs.

On the button, put the script in the “actionPerformed” event handler.

Nick[/quote]

Well, that solved the problem! I guess I should look into the actionPerformed handler more to see what it is over, rather than the property changes.

Now to fix the issue of when it hides, it stays hidden.

Instead of using a script you should probably use a tag binding in the scenario.

You should bind your tag directly to the visible property of your button. This way, if the tag is False then your visible property is False, if the tag becomes True then your visible property becomes True. If you need more logic than this then you should use an expression binding.

You should read the Ignition Manual to learn about stuff like this.
Here’s the section on tag bindings: inductiveautomation.com/support/ … inding.htm

Expression bindings:
inductiveautomation.com/support/ … inding.htm

I agree with Nick, a binding would be the cleanest, most reliable way to solve this issue.

I understand the principle behind the tag bindings, and I’ve used them for status displays (reading if a motor is “on” or “off” based off the tag state), but I’m not sure how to bind the visibility of a button to a tag, when there isn’t a “visibility” option under the property editor. As it stands now, the only things I can bind are the name, font, colors, and text.

1 Like

That is perfectly understandable.

By default you see the basic properties. To see all the properties you need to change the property filter to All.

In the Property Editor do you see the little funnel Icon with the “B” next to it? Click on the little down arrow next to the icon and select “All”. Then you will see the visible property for the component.

1 Like

Oh wow, I owe you a beverage of your choosing! I can’t believe I haven’t seen that yet. I’ve even wondered why everyone else’s screenshots and videos looked so much more in-depth than mine!

Problem solved. On to bigger and better things. Thanks again!

1 Like