GuiSetInputMode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 74480 by Srslyyyy (talk))
Tag: Undo
(Improve example.)
Line 24: Line 24:
==Example==  
==Example==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onClientResourceStart", getResourceRootElement(),
function onClientResourceStartSetGUIInputMode()
function()
guiSetInputMode("no_binds_when_editing") -- Calls guiSetInputMode once and for all to not have to handle binds state dynamically
guiSetInputMode("no_binds_when_editing") --Calls guiSetInputMode once and for all to not have to handle binds state dynamically
end
end)
addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStartSetGUIInputMode)
</syntaxhighlight>
</syntaxhighlight>



Revision as of 06:29, 30 April 2022

This function controls the input mode to define whether or not (and when) keybinds or MTA binds are overridden (disabled) so that text can be input into an editbox, for example. The binds can be either:

  • never disabled (hence using a key such as t in an editbox will still activate the chatbox)
  • always disabled (hence using a key such as t in an editbox will not activate the chatbox)
  • only disabled when actually editing an editbox or a memo (binds are always enabled except when an editbox or memo has input focus)

Syntax

bool guiSetInputMode ( string mode )

OOP Syntax Help! I don't understand this!

Method: GuiElement.setInputMode(...)
Variable: .inputMode
Counterpart: guiGetInputMode


Required Arguments

  • mode: a string representing the desired input mode. Accepted values are:
    • "allow_binds": binds are enabled, hence using a key such as t in an editbox will still activate the chatbox (default)
    • "no_binds": binds are disabled, hence using a key such as t in an editbox will not activate the chatbox
    • "no_binds_when_editing": binds are always enabled except when an editable editbox or memo has input focus

Returns

Returns true if input mode could be changed, false if invalid parameters are passed.

Example

function onClientResourceStartSetGUIInputMode()
	guiSetInputMode("no_binds_when_editing") -- Calls guiSetInputMode once and for all to not have to handle binds state dynamically
end
addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStartSetGUIInputMode)

Note

This function, introduced in 1.1, can be used as a replacement of guiSetInputEnabled since it provides the same functionality with one added feature.

  • guiSetInputEnabled ( false ) is the same as guiSetInputMode ( "allow_binds" )
  • guiSetInputEnabled ( true ) is the same as guiSetInputMode ( "no_binds" )

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI