How to update a pop-up screen in Ignition Perspective

Hi all,

I want to know how i can update a pop-up screen without reopening the popup. I’ve use a pop-up as a new view and within the popup a coordinate container for different tabs see picture
tabs 2021-11-10 151654

When i press the Auto button i write a for instance the second bit of a word, when i wrote it i want the Auto button to disappear, i’ve created a script property binding on visibility for checking if the bit value is already true, if it is true i’ve used the map function in the same property binding for writing visibility to true or false. So when is press it, the button did not disappear in the first time, but when i close and open the popup it is disappeared. Picture below for the property binding

I also tried a refresh binding, but it also without succes. The code i used is a refresh on the onClick event with a script: self.refreshBinding(self.meta.visible)

Does anybody know how i can update the popup so i don’t have to close is. And i hope you all understand it, i’m still practising my English skills haha

Regards Remco

This should do the trick.:


Your english is fine :wink:

1 Like

Hii victordcq,

Yesterday i had a day off, so i tried to implement it right now. But when i put refreshbinding in the onClick even script, below my execute command for writing a bit, it does not refresh the binding. In the picture below is the onClick script event. Did I put the refresh binding in the right script, or do I have to put it elsewhere in the program?

Really thanks for your fast reply!!

You should avoid script transforms in favour of expression transforms whenever you can as expressions are faster and have less overhead than scripts. Also, you don’t need a script transform followed by a map transform, you can just return True or False from the script (but don’t use a script here). Use expression getBit function.

Also, what does your comPareWriteNewValue function do?

The problem here is that you’re bound against a param of the popup, and that param is never going to change, so even if you refresh the binding you’re still getting the same value. Popup params are only used to construct the Popup - after that they are never used/updated again. If your UDT_Status property is relevant across multiple Views, you might look into making that property a session property. If you were to do that, then your primary View could write to the session property and the Popup could reference that property instead of a “static” param.

Now, as for what @nminchin had suggested for removing your transforms, if you could store the UDT_Status property as a boolean, that is far preferable, but if it must be a string, then you should change to an expression binding:

{session.custom.UDT_Status} != "false"

That’s all you need.

I think UDT_Status is actually a binary encoded word, and that the function he calls just pulls the bit he wants out. Obviously without seeing the function, I’m just guessing though. Regardless though, the script is explicitly returning strings which could just be returning Booleans. Or if I’m right, he could just use the expression function getBit to get the value of a bit instead which will return a bool,which could be inverted with !getBit(...)

Hii, The UDT_Status is a decimal value given from the PLC. In the PLC i have also the same UDT_Status wich is a Dword. The decimal number in the pop-up change when i press for instance the ‘Hand’ or ‘Auto’ button, but the buttons did not.

The comPareWriteNewValue function write a bit to a value you want ‘0’ or ‘1’ + I give the actual decimal number so not every bit will be written to 0. I can say comPareWriteNewValue(Actual number, 10, 1). Bit 10 will be written to true. Oke this was the function explanation haha

If I didn’t miss anything, you don’t actually need the visible property of your button to be bound to anything, you just want it to become false when it’s pressed. Is that correct ?

If that’s the case, then you can do just that: When the button is clicked, write what you want to write, then turn the visibility to false in the same script, right after your writing function call. This should be enough, with no need for refreshing manually.

self.meta.visible = False

Alternatively, I’d suggest you could disable your button with the self.props.enabled property. I’m not a fan of disappearing components.

I wouldn't do this as it could become out of sync, for example when you open and close the view, the state may not be correct. Always best to use a binding to always get the current state e.g. with getBit() in this instance

Right, I didn’t think of this. I was kind of imagining this as a one time thing, with each new popup being a new case. In which case he could have just used a one shot button…

I use the getBit() function and it works for the buttons, but when the buttons changed from ‘Hand’ to ‘Auto’ i cannot use the ‘Auto’ button, I have to re-open the pop-up and then the buttons works. Do you what I can do to fix this problem, so I don’t have to reopen the pop-up?

I don’t think I understand the problem.
What do you mean by “the buttons changed from ‘hand’ to ‘auto’” ? Aren’t they two separate buttons as shown on your screenshot in your first post ?

Can you show screenshots of how your buttons are configured? e.g. bindings on their enabled and/or visible props, onActionPerformed event handlers

Oh, I used two buttons which you can see on the screenshot. The buttons are used to set a motor in ‘Hand’ (manual) mode or in ‘Auto’ mode. When the motor is in Manual mode, The button ‘Hand’ has to disappear or in this case invisible, because i don’t like it when a user can press a button without any functionality, because it is already on manual mode, users can be distracted or confused. When the motor is in manual mode, the auto mode has to shown up.
In the first case the buttons disappear by reopening the pop-up. But with the getBit() function, the buttons changed without reopening, I can set the motor in auto mode, but when the ‘Hand’ button appear, it is not possible to change it back to manual mode, only reopening the pop-up will fix this.

This is de Auto button binding (visible)

And the Hand button binding:

I did not change the script, the only thing i change is removing the self.refreshbinding function

In this case write the bit to 0, and the auto-button script writes it to 1

what about the script on onActionPerformed?

It is exactly the same as the onClick action

How about a toggle switch ?

Have you confirmed that the tags are in the correct states when you set it to auto mode, and then after clicking the manual button? It seems like the manual button isn't writing the correct value to the tag

It actually write the tags correct. pressing the auto button adds decimal number 2 on the existed value. so if al 32 bits are 0, and clicking the ‘Auto’ button the decimal number is 2 in auto modus (UDT value), otherwise the decimal number will be zero. In the previous screenshot you see a 50mil number, this is because the PLC program has an Alarm.

In the onClick (I deleted it, and use the onActionPerformed) you see the function comPareNewWriteValue(). Pressing the Hand button write bit 1 to a 0, and the Auto button writes bit 1 to 1.