GuiSetProperty: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 19: Line 19:
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">
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
 
     function()
     function()
         button = guiCreateButton(20, 200, 150, 30, "Test", false)
         button = guiCreateButton(20, 200, 150, 30, "Test", false)
     end
     end
)
end
 
addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()) )


addCommandHandler("togglebtn",
     function toogleButton ( )
     function()
         local currentState = guiGetProperty(button, "Disabled")
         local currentState = guiGetProperty(button, "Disabled")
         if currentState == "False" then
         if currentState == "False" then
Line 34: Line 35:
         end
         end
     end
     end
)
end
 
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}}

Revision as of 05:58, 29 June 2009

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 wiki page.

Syntax

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

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.

Example

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()
        button = guiCreateButton(20, 200, 150, 30, "Test", false)
    end
end

addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()) )

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

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 )

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