GuiEditSetReadOnly: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (OOP syntax)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
{{Client function}}
This function allows you to set or remove read-only status for an edit box. If read-only is set to ''true'', the box is not editable.
This function allows you to set or remove read-only status for an edit box. If read-only is set to ''true'', the box is not editable.


==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiEditSetReadOnly ( element theElement, bool status )
bool guiEditSetReadOnly ( element editField, bool status )
</syntaxhighlight>  
</syntaxhighlight>
{{OOP||[[Element/GUI/Edit_field|GuiEdit]]:setReadOnly|readOnly|guiEditIsReadOnly}}


===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''editField:''' The element of the [[Element/GUI/Edit field|edit field]] to be modified.
*'''theElement:''' The edit box to be changed.
*'''status:''' A boolean value indicating whether read-only is to be enabled or disabled.
*'''status:''' A boolean value indicating whether read-only is to be enabled or disabled.


===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 edit field's read-only status was changed successfully, ''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 a little advert field on the bottom right corner of the screen and sets it to read only.
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...
myWebsite = "development.mtasa.com" -- define the text to be displayed in advert field
blabhalbalhb --abababa
function createAdvert( )
--This line does this...
    local advert = guiCreateEdit( 0.845, 0.94, 0.15, 0.05, myWebsite, true ) -- create edit field for the advert
mooo
    if advert then -- if it was successfully created
        guiEditSetReadOnly( advert, true ) -- make it read only
    end
end
addEventHandler ( "onClientResourceStart", getResourceRootElement( getThisResource() ), createAdvert )
</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 20:57, 7 November 2018

This function allows you to set or remove read-only status for an edit box. If read-only is set to true, the box is not editable.

Syntax

bool guiEditSetReadOnly ( element editField, bool status )

OOP Syntax Help! I don't understand this!

Method: GuiEdit:setReadOnly(...)
Variable: .readOnly
Counterpart: guiEditIsReadOnly


Required Arguments

  • editField: The element of the edit field to be modified.
  • status: A boolean value indicating whether read-only is to be enabled or disabled.

Returns

Returns true if edit field's read-only status was changed successfully, false otherwise.

Example

This example creates a little advert field on the bottom right corner of the screen and sets it to read only.

myWebsite = "development.mtasa.com" -- define the text to be displayed in advert field
function createAdvert( )
    local advert = guiCreateEdit( 0.845, 0.94, 0.15, 0.05, myWebsite, true ) -- create edit field for the advert
    if advert then -- if it was successfully created
        guiEditSetReadOnly( advert, true ) -- make it read only
    end
end
addEventHandler ( "onClientResourceStart", getResourceRootElement( getThisResource() ), createAdvert )

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