GuiSetProperty: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Replace to predefined variables.)
 
(11 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This function sets the value of a specific CEGUI property of a GUI element. For a list of properties and their meaning, see the [http://www.cegui.org.uk/wiki/index.php/SetProperty_(WindowsLook) CEGUI properties wiki page].
This function sets the value of a specific CEGUI property of a GUI element. For a list of properties and their meaning, see the [http://static.cegui.org.uk/static/WindowsLookProperties.html CEGUI properties page].


==Syntax==
==Syntax==
Line 7: Line 7:
bool guiSetProperty ( element guiElement, string property, string value )
bool guiSetProperty ( element guiElement, string property, string value )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[GUI widgets|GuiElement]]:setProperty||guiGetProperty}}


===Required Arguments===
===Required Arguments===
Line 16: Line 17:
If the function succeeds it returns ''true'', if it fails it returns ''false''.
If the function succeeds it returns ''true'', if it fails it returns ''false''.


==Example==
==Examples==
This example creates a button when the resource starts and defines a console command that toggles it between enabled (clickable) and disabled (not clickable).
This example creates a button when the resource starts and defines a console command that toggles it between enabled (clickable) and disabled (not clickable).
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">


    function()
function onStart()
        button = guiCreateButton(20, 200, 150, 30, "Test", false)
  button = guiCreateButton( 20, 200, 150, 30, "Test", false )
    end
end
end
addEventHandler( "onClientResourceStart", resourceRoot, onStart )


addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()) )
function toogleButton()
 
  local currentState = guiGetProperty( button, "Disabled" )
    function toogleButton ( )
  if currentState == "False" then
        local currentState = guiGetProperty(button, "Disabled")
    guiSetProperty( button, "Disabled", "True" )
        if currentState == "False" then
  else
            guiSetProperty(button, "Disabled", "True")
    guiSetProperty( button, "Disabled", "False" )
        else
  end
            guiSetProperty(button, "Disabled", "False")
end
        end
addCommandHandler( "togglebtn", toogleButton )
    end
</syntaxhighlight>
This example creates a button when the resource starts and defines its normal color to red and hover color to yellow.
<syntaxhighlight lang="lua">
function onStart()
  button = guiCreateButton (20, 200, 150, 30, "Test", false)
  guiSetProperty (button, "NormalTextColour", "FFFF0000") -- Color format: AARRGGBB
  guiSetProperty (button, "HoverTextColour", "FFFFFF00")
end
end
 
addEventHandler ("onClientResourceStart", resourceRoot, onStart)
addCommandHandler("togglebtn", toogleButton )
-- There was lots of bugs so i edited this script if you have found more please edit because i am starting scripter. ( faiLL )
</syntaxhighlight>
</syntaxhighlight>


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

Latest revision as of 23:13, 11 January 2023

This function sets the value of a specific CEGUI property of a GUI element. For a list of properties and their meaning, see the CEGUI properties page.

Syntax

bool guiSetProperty ( element guiElement, string property, string value )

OOP Syntax Help! I don't understand this!

Method: GuiElement:setProperty(...)
Counterpart: guiGetProperty


Required Arguments

  • guiElement: the GUI element you wish to get a property of.
  • property: the name of of property you want the value of.
  • value: the new value for the property.

Returns

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

Examples

This example creates a button when the resource starts and defines a console command that toggles it between enabled (clickable) and disabled (not clickable).


function onStart()
  button = guiCreateButton( 20, 200, 150, 30, "Test", false )
end
addEventHandler( "onClientResourceStart", resourceRoot, onStart )

function toogleButton()
  local currentState = guiGetProperty( button, "Disabled" )
  if currentState == "False" then
    guiSetProperty( button, "Disabled", "True" )
  else
    guiSetProperty( button, "Disabled", "False" )
  end
end
addCommandHandler( "togglebtn", toogleButton )

This example creates a button when the resource starts and defines its normal color to red and hover color to yellow.

function onStart()
  button = guiCreateButton (20, 200, 150, 30, "Test", false)
  guiSetProperty (button, "NormalTextColour", "FFFF0000") -- Color format: AARRGGBB
  guiSetProperty (button, "HoverTextColour", "FFFFFF00")
end
addEventHandler ("onClientResourceStart", resourceRoot, onStart)

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