GuiSetEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 51816 by Thisdp (talk))
(Sheva's code is shorter and should work)
 
(6 intermediate revisions by 4 users not shown)
Line 7: Line 7:
bool guiSetEnabled ( element guiElement, bool enabled )
bool guiSetEnabled ( element guiElement, bool enabled )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[GUI widgets|GuiElement]]:setEnabled|enabled|guiGetEnabled}}


===Required Arguments===
===Required Arguments===
Line 18: Line 19:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">function ChangeMyButtonEnabled ( )         
<syntaxhighlight lang="lua">function ChangeMyButtonEnabled ( )         
        if ( guiGetEnabled ( MyButton ) == true ) then -- check if the element is enabled         
    guiSetEnabled ( MyButton, not guiGetEnabled ( MyButton ) ) -- enable button if disabled. Disable if enabled
                guiSetEnabled ( MyButton, false ) -- if it is, we disable it
        else             
                guiSetEnabled ( MyButton, true ) -- if not, we make it enabled
        end
end
end
MyGuiWindow = guiCreateWindow(254,206,478,306,"Awesome Gui Window",false) -- Your gui window
MyGuiWindow = guiCreateWindow(254,206,478,306,"Awesome Gui Window",false) -- Your gui window
MyButton = guiCreateButton(0.477,0.8268,0.1946,0.0784,"Hello World!",true,MyGuiWindow) -- Creates a button in your gui window</syntaxhighlight></section>
MyButton = guiCreateButton(0.477,0.8268,0.1946,0.0784,"Hello World!",true,MyGuiWindow) -- Creates a button in your gui window
ChangeMyButtonEnabled ( ) -- Execute function </syntaxhighlight></section>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
{{GUI_events}}

Latest revision as of 13:49, 14 May 2019

This function enables/disables a GUI element. A disabled GUI element can't be used, gets a gray aspect and doesn't receive any events.

Syntax

bool guiSetEnabled ( element guiElement, bool enabled )

OOP Syntax Help! I don't understand this!

Method: GuiElement:setEnabled(...)
Variable: .enabled
Counterpart: guiGetEnabled


Required Arguments

  • guiElement: the GUI element you wish to enable or disable
  • enabled: the new state

Returns

If the function succeeds it returns true, if it fails it returns false.

Example

Click to collapse [-]
Client
function ChangeMyButtonEnabled ( )        
    guiSetEnabled ( MyButton, not guiGetEnabled ( MyButton ) ) -- enable button if disabled. Disable if enabled
end
MyGuiWindow = guiCreateWindow(254,206,478,306,"Awesome Gui Window",false) -- Your gui window
MyButton = guiCreateButton(0.477,0.8268,0.1946,0.0784,"Hello World!",true,MyGuiWindow) -- Creates a button in your gui window
ChangeMyButtonEnabled ( ) -- Execute function 

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