Squirrel/Client/Functions/GUIButton/Colour
From Liberty Unleashed Wiki
(Difference between revisions)
m (fail title) |
(Added example) |
||
Line 13: | Line 13: | ||
== Example 1. Returning == | == Example 1. Returning == | ||
− | + | This code will message the player with the RGB values of a button when they click on one. | |
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onClientClickButton( button ) | |
+ | { | ||
+ | Message( "R: " + button.Colour.r ); | ||
+ | Message( "G: " + button.Colour.g ); | ||
+ | Message( "B: " + button.Colour.b ); | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The event [[Squirrel/Client/Events/GUI/onClientClickButton|onClientClickButton]] and function [[Squirrel/Client/Functions/Messages/Message|Message]] were used in this example. More information can be found on their corresponding pages. | |
== Example 2. Setting == | == Example 2. Setting == | ||
− | + | This code will make a button absolutely blue when clicked on. | |
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onClientClickButton( button ) | |
+ | { | ||
+ | button.Colour = Colour(0, 0, 255); | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The event [[Squirrel/Client/Events/GUI/onClientClickButton|onClientClickButton]] and script type [[Squirrel/Script_Types/Colour|Colour]] were used in this example. More information can be found on their corresponding pages. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Client/Functions/GUIButton}} | {{Squirrel/Client/Functions/GUIButton}} |
Latest revision as of 23:07, 2 August 2011
This member variable sets/returns the colour of the button.
[edit] Syntax
Colour GUIButton.Colour
GUIButton.Colour = Colour col
[edit] Arguments
- col - This is a Colour class object
[edit] Example 1. Returning
This code will message the player with the RGB values of a button when they click on one.
function onClientClickButton( button ) { Message( "R: " + button.Colour.r ); Message( "G: " + button.Colour.g ); Message( "B: " + button.Colour.b ); }
[edit] Notes
The event onClientClickButton and function Message were used in this example. More information can be found on their corresponding pages.
[edit] Example 2. Setting
This code will make a button absolutely blue when clicked on.
function onClientClickButton( button ) { button.Colour = Colour(0, 0, 255); }
[edit] Notes
The event onClientClickButton and script type Colour were used in this example. More information can be found on their corresponding pages.