[SOLVED] Handling enter key - overriding default chat enter

[SOLVED] Handling enter key - overriding default chat enter

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

[SOLVED] Handling enter key - overriding default chat enter

Post by gajop »

1. Is it possible to handle the "Enter" key press somehow? Seems like it's being captured by the engine and used to start/stop typing a chat message, but it doesn't get passed to widgets (or at least some widget could be capturing it before mine).

2. It seems the numpad "Enter" key is never being passed, but it doesn't work for chat message typing either.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Handling enter key press - overriding default chat enter

Post by gajop »

Nevermind, I was doing something wrong, not sure what that was.
PS: for future reference, it seems the numpad enter is 271 (KP_ENTER), while the normal enter is 13 (ENTER).
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Handling enter key press - overriding default chat enter

Post by jK »

please stop comparing symkeys, instead compare the string name of it.

It was a lot work to fix those symkeys in the SDL2 switch, cause they changed and aren't said to be stable at all ...
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Handling enter key press - overriding default chat enter

Post by gajop »

jK wrote:please stop comparing symkeys, instead compare the string name of it.
Sure, but how?
In Chili's editobox.lua 'Spring.GetKeyCode("backspace")' is mentioned (I guess you wrote that), but spring 96.0 tells me that function doesn't exist.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: [SOLVED] Handling enter key - overriding default chat en

Post by jK »

http://springrts.com/wiki/Lua_UnsyncedR ... ot-.29Keys
it's not new

and you can also use Spring.GetKeySymbol
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: [SOLVED] Handling enter key - overriding default chat en

Post by gajop »

OK, seems to actually work, thanks.
Post Reply

Return to “Lua Scripts”