Confirmation pop up on Numeric text field


I need to have a ‘Are you sure’ pop up on numeric text field before the operator can actually enter values. I know it could be done by system.gui.confirm, but could someone please help me with the correct script for it?
Also what will happen if the operator chooses no ? will the pop up disappear and go back to the numeric text field for the operator to click on it again?


In that example code they are using system.db.runupdatequery which I dont need in my case. When I delete that code and just keep system.gui.confirm, it gives me an error. Could you please help me further? I am new to python coding.

Oops, I didn’t read your question correctly. I’m not 100% sure on the best method for that. Maybe use system.gui.inputBox instead.

Add a custom property holding the previous value (my example is prevValue).

In a propertyChange script:

if event.propertyName == 'value':
	if event.source.value != event.source.prevValue:
		if system.gui.confirm("Are you sure?"):
			event.source.prevValue = event.newValue
			event.source.value = event.source.prevValue

EDIT: almost but not quite. I’d perhaps add one more custom property as a control value and write to that. There’s no way to intercept the value before being written to say, a tag. using a control value will help with that.

I am still finding it hard to understand. Do you mean adding custom property on the text field?
Here is what I am trying to do

So every time the operator clicks on that numeric field box, a confirmation pop up should appear.

Event Handlers

  • focusGained

This event occurs when a component that can receive input, such as a text box, receives the input focus. This usually occurs when a user clicks on the component or tabs over to it.
Link to the docs