Skip to content

Add TextInput hook

Hanicef requested to merge Hanicef/SRB2:add-textinput-hook into next

With !1952 (merged) being queued up for 2.2.14, it would only be logical to expose that API to Lua, so scripters can take advantage of this, too. This also complements KeyDown and KeyUp hooks, but due to technical reasons around dead keys and such, TextInput won't be invoked unless input.setTextInputMode is called first (this is also true for the engine; there is no exception for Lua here).

Example script:

addHook("MapLoad", function (mapnumber)
  input.setTextInputMode(true)
end)
addHook("TextInput", function (textevent)
  print(textevent.text)
end)
Edited by Hanicef

Merge request reports

Loading