GuiEditSetMaxLength: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
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.



Revision as of 21:43, 4 August 2007

This function sets the maximum text length that can be typed into an edit box.

Syntax

bool guiEditSetMaxLength ( element theElement, int length )

Required Arguments

  • theElement: The edit box to be changed.
  • lenth: 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 alongside an "Output!" button. When the button is clicked, it will output the message in the edit box into the Chat Box.

--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 )
-- and attach our button to the outputEditBox function
addEventHandler ( "onClientClick", editBox, outputEditBox )
guiEditSetMaxLength ( editBox, 128 ) --the max chatbox length is 128, so force this

--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 ( "onClientClick", button, outputEditBox )

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