Godot Version
4.3
Question
I’ve more or less set up my input order (the “Using InputEvent” chart is most helpful). However, there’s still an area that isn’t explained there well enough - or that I just failed to understand. I can work around that, but I thought I’d rather ask & learn.
Consider the following two scenarios:
-
A button has a Shortcut assigned to it. As usual, it has a “button pressed” signal which connects to the parent control’s “on_button_pressed”. However, if that button wasn’t actually pressed but rather activated with a shortcut – how can “on_button_pressed” stop that key press from propagating? There’s no “event” argument; “accept_event()” does nothing; mouse filter doesn’t apply.
(if left alone, it does propagate to _unhandled_key_input() of other nodes, I’ve checked). -
A button has no shortcuts, but it is focused and was “pressed” using the “ui_accept” key. Usually spacebar. Once again, where would I intercept that press to set it as handled? Doing this in “on_button_pressed” does nothing, same as in the example above.
These seem like more or less the same case: a button is activated with a key but treats it as a mouse click. Sure, I can avoid shortcuts altogether and handle key presses in _unhandled_key_input(), but a) that’s just avoiding a tool that I couldn’t figure out; b) that’s less feasible with focus (which gets handled “under the hood”). So how do I intercept that press?