How do I deal with spinbox so that I can differentiate between a programmatic changed and change from the UI?

The only way I know is to create my own custom control that changes the value programmatically and tells it to emit two different signals for the programmatic value change and non-programmatic value change.

  • zerohootsoliver Is there not any situations you can think of, were this would be useful?

    To be honest, no, not really. Can you name a few?

    But if you want your spinbox class to provide the option of setting the value without emitting the signal, you can have a dedicated method. For example:

    extends SpinBox
    func set_value_noemit(v):
    	set_block_signals(true)
    	self.value = v
    	set_block_signals(false)

xyz

xyz Because if I want to change a value when the spinbox changes, I can change it in the UI. But if that code doesn't need to be re-executed then I can change it without triggering another change to that value.

Is there not any situations you can think of, were this would be useful? For example, LineEdit and TextEdit, I believe, handle it differently to spinbox so I assume it has a use?

  • xyz replied to this.

    zerohootsoliver Is there not any situations you can think of, were this would be useful?

    To be honest, no, not really. Can you name a few?

    But if you want your spinbox class to provide the option of setting the value without emitting the signal, you can have a dedicated method. For example:

    extends SpinBox
    func set_value_noemit(v):
    	set_block_signals(true)
    	self.value = v
    	set_block_signals(false)

      xyz the use case is when you have code elsewhere that sets the value. Like if scroll your mouse wheel or the value is set in a different piece of UI. And it sets the spinbox value. You wouldn't want to retrigger, changing the variable value that the spinbox is linked to.

      This should probably be something built-in, to be consistent with controls like LineEdit and TextEdit. But I am using your suggestion for now.

      • xyz replied to this.