GuiEditSetMasked: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(8 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Client_function}}
{{Client_function}}
__NOTOC__  
__NOTOC__  
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
This function sets or removes masking (covering up the text being typed) for password text fields.
This function sets or removes masking (covering up the text being typed) for password text fields.


Line 8: Line 7:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiEditSetMasked ( element theElement, bool status )
bool guiEditSetMasked ( element theElement, bool status )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Edit_field|GuiEdit]]:setMasked|masked|guiEditIsMasked}}
 
[[File:EditBox.png|thumb|A masked text]]


===Required Arguments===  
===Required Arguments===  
Line 16: Line 18:


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the function is successful, ''false'' otherwise.
Returns ''true'' if the function is successful, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example creates an edit box and an OK button. The user types in his password, and it checks if the password was correct
This example does...
<!-- 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">
--This line does...
-- set our password
blabhalbalhb --abababa
password = "cheeseman"
--This line does this...
 
mooo
-- create our button
button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "OK", true )
-- create an edit box and define it as "editBox"
editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "", true )
-- ensure that it is masked
guiEditSetMasked ( editBox, true )
 
-- set up our function to output the message to the chatbox
function checkPassword ()
        local text = guiGetText ( editBox )    -- get the text from the edit box
        if text == password then                -- if the text matches the password
                outputChatBox ( "Password Correct!" )
        else
                outputChatBox ( "Password Incorrect!" )
        end
end
-- set the function to be called when the OK button is clicked
addEventHandler ( "onClientGUIClick", button, checkPassword )
 
</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 -->
{{GUI_functions}}
{{GUI_functions}}
[[Category:Incomplete]]
{{GUI_events}}

Latest revision as of 14:20, 27 April 2020

This function sets or removes masking (covering up the text being typed) for password text fields.

Syntax

bool guiEditSetMasked ( element theElement, bool status )

OOP Syntax Help! I don't understand this!

Method: GuiEdit:setMasked(...)
Variable: .masked
Counterpart: guiEditIsMasked


A masked text

Required Arguments

  • theElement: The edit box to be changed.
  • status: A boolean value indicating whether masking is to be enabled or disabled.

Returns

Returns true if the function is successful, false otherwise.

Example

This example creates an edit box and an OK button. The user types in his password, and it checks if the password was correct

-- set our password
password = "cheeseman"

-- create our button
button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "OK", true )
-- create an edit box and define it as "editBox"
editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "", true )
-- ensure that it is masked
guiEditSetMasked ( editBox, true )

-- set up our function to output the message to the chatbox
function checkPassword ()
        local text = guiGetText ( editBox )     -- get the text from the edit box
        if text == password then                -- if the text matches the password
                outputChatBox ( "Password Correct!" )
        else
                outputChatBox ( "Password Incorrect!" )
        end
end
-- set the function to be called when the OK button is clicked
addEventHandler ( "onClientGUIClick", button, checkPassword )

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