PDA

View Full Version : Keyboard use on a control



Xarxus
May 28th, 2023, 17:23
Is there a way to intercept the keypress event on a control?
Something like keydown, keyup

Zacchaeus
May 28th, 2023, 17:52
I think keypresses are handled by the Unity engine itself and then passed to FG. So I think you'd need to intercept them from outside FG - but I'm no expert in this.

Moon Wizard
May 28th, 2023, 23:51
Look at windowcontrol.onClickDown/onClickRelease. There are tons of examples in the built-in rulesets.

If you just need a button, you can look at buttoncontrol.onButtonPressed too.

Regards,
JPG

Xarxus
May 29th, 2023, 09:58
Look at windowcontrol.onClickDown/onClickRelease. There are tons of examples in the built-in rulesets.

If you just need a button, you can look at buttoncontrol.onButtonPressed too.

Regards,
JPG

Those are mouse events. I was talking about keyboard events.
Do they react even to keyboard?

damned
May 29th, 2023, 12:16
There are functions for IsControlPressed and onControl and the same for Shift and Alt

https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644619/Input

That might be the limit.

Xarxus
May 29th, 2023, 20:10
What I'd like to do is change a selection in a windowlist on pressing arrows on the keyboard. From what I see in
the Input API there are events only for pressing the Alt, Control and Shift keys.

I think they can be used with a statement like
Input.addEventHandler("onAlt", myFunction);
How do I intercept the arrow keys?

damned
May 29th, 2023, 22:13
Im pretty sure you cant.

Moon Wizard
May 29th, 2023, 23:48
Only text controls support any sort of arrow navigation events. It really hasn't come up as a needed capability more than once or twice in the last 12 years. For text controls, the events are onNavigateLeft, onNavigateRight, onNavigateUp, onNavigateDown; and they will only trigger when on the boundary of the field (i.e. arrow left when in zero character position; arrow right in last character position; arrow down when on last line; arrow up when on first line).

Regards,
JPG