GuiGetText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Remove redundant comment)
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Client function}}
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
__NOTOC__
This function is used to get text from GUI elements like edit boxes, labels, buttons, etc.
This function is used to get the text of GUI elements like edit boxes, labels, buttons etc.


==Syntax==  
==Syntax==  
Line 7: Line 7:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string guiGetText ( element guiElement )
string guiGetText ( element guiElement )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[GUI widgets|GuiElement]]:getText|text|guiSetText}}


===Required Arguments===  
===Required Arguments===  
Line 22: Line 23:
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function test ()
-- We create a dummy gui label to get text of
--we create a dummy gui label to get text of
local dummyGUIElement = guiCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )
local dummyGuiElement = guiCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )
-- Output the text of the label to chat box
--output the text of the label to chat box
outputChatBox ( "Text in the GUI label: " .. guiGetText ( dummyGUIElement ) )
outputChatBox ( "Text in the GUI label: "..guiGetText ( dummyGuiElement ) )
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{FunctionArea_functions}}
{{GUI_functions}}
[[Category:Need_Syntax]]  -- leave this until syntax is available. Cannot document the function or event without syntax.
{{GUI_events}}
[[Category:Incomplete]] -- leave this unless you complete the function

Latest revision as of 08:06, 5 August 2021

This function is used to get the text of GUI elements like edit boxes, labels, buttons etc.

Syntax

string guiGetText ( element guiElement )

OOP Syntax Help! I don't understand this!

Method: GuiElement:getText(...)
Variable: .text
Counterpart: guiSetText


Required Arguments

  • guiElement: element you wish to get text of.

Returns

Returns a string containing the requested element's text, or false if the gui element passed to the function is invalid.

Example

This example gets the text of a pre-made gui element and outputs it to chat box.

-- We create a dummy gui label to get text of
local dummyGUIElement = guiCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )
-- Output the text of the label to chat box
outputChatBox ( "Text in the GUI label: " .. guiGetText ( dummyGUIElement ) )

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