GuiEditSetMasked: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 20: Line 20:
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 creates an edit box and an OK button.  The user types in his password, and it checks if the password was correct
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
password = "cheeseman" --set our password
-- set our password
password = "cheeseman"


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


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



Revision as of 18:16, 18 August 2007

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

Syntax

bool guiEditSetMasked ( element theElement, bool status )

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