DgsSetEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsSetEnabled ( element dgsElement, bool enabled )
bool dgsSetEnabled ( element/table dgsElement, bool enabled )
</syntaxhighlight>
</syntaxhighlight>
{{DGS/OOP|
    Method = DGSElement:setEnabled|
    Variable = enabled|
    Counterpart = dgsGetEnabled
}}


===Required Arguments===
===Required Arguments===
Line 20: Line 25:
DGS = exports.dgs
DGS = exports.dgs
function ChangeMyButtonEnabled ( )         
function ChangeMyButtonEnabled ( )         
         if ( DGS:dgsDxGUIGetEnabled ( MyButton ) == true ) then -- check if the element is enabled           
         if ( DGS:dgsGetEnabled ( MyButton ) == true ) then -- check if the element is enabled           
                 DGS:dgsDxGUISetEnabled ( MyButton, false ) -- if it is, we disable it
                 DGS:dgsSetEnabled ( MyButton, false ) -- if it is, we disable it
         else               
         else               
                 DGS:dgsDxGUISetEnabled ( MyButton, true ) -- if not, we make it enabled
                 DGS:dgsSetEnabled ( MyButton, true ) -- if not, we make it enabled
         end
         end
end
end


MyGuiWindow = DGS:dgsDxCreateWindow(254,206,478,306,"Awesome dgs Window",false) -- Your dgs window
MyGuiWindow = DGS:dgsCreateWindow(254,206,478,306,"Awesome dgs Window",false) -- Your dgs window
MyButton = DGS:dgsDxCreateButton(0.477,0.8268,0.1946,0.0784,"Hello World!",true,MyGuiWindow) -- Creates a button in your dgs window</syntaxhighlight></section>
MyButton = DGS:dgsCreateButton(0.477,0.8268,0.1946,0.0784,"Hello World!",true,MyGuiWindow) -- Creates a button in your dgs window</syntaxhighlight></section>


==See Also==
=See Also=
{{DGSFUNCTIONS}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>==
{{DGS General Functions}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>==
{{DGS Events/General}}

Latest revision as of 18:50, 11 June 2024

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

Syntax

bool dgsSetEnabled ( element/table dgsElement, bool enabled )

DGS OOP Syntax Help! I don't understand this!

Method: DGSElement:setEnabled(...)
Variable: .enabled
Counterpart: dgsGetEnabled

Required Arguments

  • dgsElement: the DGS 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
DGS = exports.dgs
function ChangeMyButtonEnabled ( )        
        if ( DGS:dgsGetEnabled ( MyButton ) == true ) then -- check if the element is enabled           
                DGS:dgsSetEnabled ( MyButton, false ) -- if it is, we disable it
        else              
                DGS:dgsSetEnabled ( MyButton, true ) -- if not, we make it enabled
        end
end

MyGuiWindow = DGS:dgsCreateWindow(254,206,478,306,"Awesome dgs Window",false) -- Your dgs window
MyButton = DGS:dgsCreateButton(0.477,0.8268,0.1946,0.0784,"Hello World!",true,MyGuiWindow) -- Creates a button in your dgs window

See Also

General Functions

General Events