GuiEditSetMaxLength: Difference between revisions
Jump to navigation
Jump to search
JonChappell (talk | contribs) No edit summary |
Dutchman101 (talk | contribs) m (t) |
||
(10 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | |||
This function sets the maximum text length that can be typed into an edit box. | This function sets the maximum text length that can be typed into an edit box. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool guiEditSetMaxLength ( element | bool guiEditSetMaxLength ( element guiEdit, int length ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[Element/GUI/Edit_field|GuiEdit]]:setMaxLength|maxLength|guiEditGetMaxLength}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theElement:''' The edit box to be changed. | *'''theElement:''' The edit box to be changed. | ||
*''' | *'''length:''' An integer indicating the maximum number of characters that can be typed into the box. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the max length was set successfully, ''false'' otherwise. | |||
Returns ''true'' if the | |||
==Example== | ==Example== | ||
This example creates an edit box with a limit on text length, alongside an "Output!" button. When the button is clicked, it will output the message in the edit box into the chatbox. | |||
This example | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | -- create our button | ||
button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) | |||
-- create an edit box and define it as "editBox". | |||
editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) | |||
-- set a maximum text length of 128 characters | |||
guiEditSetMaxLength ( editBox, 128 ) | |||
-- setup our function to output the message to the chatbox | |||
function outputEditBox () | |||
local text = guiGetText ( editBox ) -- get the text from the edit box | |||
outputChatBox ( text ) -- output that text | |||
end | |||
addEventHandler ( "onClientGUIClick", button, outputEditBox ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{GUI_functions}} | {{GUI_functions}} | ||
[[ | {{GUI_events}} | ||
[[RU:guiEditSetMaxLength]] |
Latest revision as of 21:53, 12 December 2020
This function sets the maximum text length that can be typed into an edit box.
Syntax
bool guiEditSetMaxLength ( element guiEdit, int length )
OOP Syntax Help! I don't understand this!
- Method: GuiEdit:setMaxLength(...)
- Variable: .maxLength
- Counterpart: guiEditGetMaxLength
Required Arguments
- theElement: The edit box to be changed.
- length: An integer indicating the maximum number of characters that can be typed into the box.
Returns
Returns true if the max length was set successfully, false otherwise.
Example
This example creates an edit box with a limit on text length, alongside an "Output!" button. When the button is clicked, it will output the message in the edit box into the chatbox.
-- create our button button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) -- create an edit box and define it as "editBox". editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) -- set a maximum text length of 128 characters guiEditSetMaxLength ( editBox, 128 ) -- setup our function to output the message to the chatbox function outputEditBox () local text = guiGetText ( editBox ) -- get the text from the edit box outputChatBox ( text ) -- output that text end addEventHandler ( "onClientGUIClick", button, outputEditBox )
See Also
General functions
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign
Windows
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel