OptionButton inconsistent scroll behaviour

OptionButtons seems to have their own unique scroll behaviour in response to ui_down/right/left/up. Instead of scrolling immidiately when you input an ui_down it instead requires the button to be held for an arbitrary amount of time.

I’m currently using an autoload code to simulate custom repeat rate for UI elements and the inconsistent OptionButton behaviour with the rest of the UI is a problem for me. Is there any way to prevent OptionButton from autorepeating on its own and instead go down/up as you press ui_down/up once.

Here the autoload script I’m using for the ui currently (stripped down only for the ui_down code):

extends Node

const INITIAL_REPEAT_RATE := 0.15
const REPEAT_RATE := 0.07

var down_repeat: float = INITIAL_REPEAT_RATE


func _physics_process(delta: float) -> void:
	if Input.is_action_pressed("private_ui_down"):
		down_repeat -= delta
		if down_repeat <= 0:
			_simulate_key("ui_down")
			down_repeat = REPEAT_RATE


func _input(event: InputEvent) -> void:
	if event.is_action_pressed("private_ui_down"):
		down_repeat = INITIAL_REPEAT_RATE
		_simulate_key("ui_down")
		return


func _simulate_key(key_string: String):
	var ev = InputEventAction.new()
	ev.action = key_string
	ev.pressed = true
	Input.parse_input_event(ev)

This is most likely because when the OptionButton is instantiated, it creates a PopupMenu child that handles the items and selections. You can see that when you check the Remote mode after you run the game.
image

PopupMenu inherits from Viewport, which means it handles input completely separate from your main Viewport.
image

It might not solve your problem, but at least gives you an idea why it behaves differently than you might expect.

1 Like