One-Shot Button Close Popup

In Perspective (Ignition 8.1.35), I'm trying to use a one-shot button to close a popup view using an onActionPerformed event.

Whilst the popup successfully closes, the one-shot button does NOT write the setValue to the tag bound to value.

I know it's not an issue with the binding, because if I remove the onActionPerformed event, the one-shot button writes to value correctly.

I suspect the issue is that the popup is being closed before the one-shot button has a chance to perform the write.

Is this something that could be fixed in the way the one-shot button behaves (only execute the onActionPerformed events after the write has successfully occurred)?

I'm guessing the popup closes before the write happens... And then the whole thing just stops existing so there's nothing to write.

Switch to a script, use system.tag.writeBlocking to write to your tag, then system.tag.closePopup.

5 Likes

Don't do this. Use system.perspective.closePopup. :rofl:

6 Likes

Probably a good idea.

3 Likes

Thanks tor the advice pascal and cmallonee, and yes we’ll use a script with those 2 lines.

But, doesn’t this seem like a shortcoming of the popup window or one-shot button that should be fixed? Should the design of the one-shot button be such that it always issues its write command before “onActionPerformed” is called? I’m not proposing it needs to have finished the write (blocking), just that it sends the write and then calls the onActionPerformed events.

I don't think so, no. I think the greater concern here is that you should not develop UI where a single click is expected to take more than one action. I'm well aware there will be detractors against this stance, but in my mind one click should result in one action. In your scenario, a click writes some value (setValue of the One-Shot Button) AND closes a Popup. It seems like there should be a One-Shot Button which does it's thing, and a regular Button which closes the Popup.

The pop up is being used as a confirmation of a button click.

A button on the main view opens the popup, and then a button on the popup confirms and performs the action.

We want this to be a 2 click process for the user - click to request, click to confirm, confirmation popup closes.

We don’t want a third click to close the confirmation popup.

We can’t use the confirmation built into the one-shot button, because this process also has a 3-way handshake to the PLC in the background (invisible to the user) - meaning we need to write-read-write whilst this 2-click user confirmation process is happening.

Then it sounds like you should just be using a button to perform the action instead of trying to force a One-Shot Button to work for your use-case.

Okidoki, thanks

I suggest you rework this to use a message handler instead. It will abstract the logic from the popup, and allow you to reuse the confirmation popup for other cases.
And it puts the logic back to where the popup was called, through a message handler.

3 Likes