WoW:API CheckButton SetChecked: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (Move page script moved page API CheckButton SetChecked to API CheckButton SetChecked without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{widgetmethod}} __NOTOC__
{{widgetmethod}} __NOTOC__


Sets the status of a CheckButton.
Sets the checked status of a CheckButton frame.
 
  CheckButton:SetChecked(State);
  CheckButton:SetChecked(State);


== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===
:(State)
:;state :{{api|boolean|t=t}} - 'true' sets the button state to checked. Default is 'false'.
 
:;State : Mixed - Basically expressions LUA evaluates to '''true''' will check the button. Everything else will uncheck.


=== Returns ===
=== Returns ===
:nil
: none


:;nil : This function will always return nil.
== Examples ==
----
CheckButton:SetChecked(true)


== Example ==
CheckButton:SetChecked(true);
CheckButton:SetChecked(1);
CheckButton:SetChecked(-2397);
CheckButton:SetChecked("-2397");
CheckButton:SetChecked({1,2,3});
CheckButton:SetChecked("foo");
CheckButton:SetChecked();
====Result====
Button is checked
Button is checked


== Example ==
  CheckButton:SetChecked(false)
  CheckButton:SetChecked(false);
  CheckButton:SetChecked(0)
  CheckButton:SetChecked(0);
  CheckButton:SetChecked(nil)
  CheckButton:SetChecked(nil);
CheckButton:SetChecked()
CheckButton:SetChecked({1,2,3})
CheckButton:SetChecked("true")


====Result====
Button is unchecked
Button is unchecked


== Notes ==
* Passing "nil" will uncheck the button, but passing *no* argument (although it should end up being nil for Lua) will enable it, also passing a table ({...}) will now check the button.
* As of WoW 6.0 both GetChecked() and SetChecked() use Lua boolean values only. Passing value other than Lua {{api|boolean|t=t}} 'true' is the same as passing 'false', and GetChecked() will only return true or false.  Prior to 6.0.2 values such as true, 1, -2397, {1,2,3}, "foo" would all set state as checked. Values such as false, 0, nil would set state as not checked.


----
== See also ==
====Patch 1.11 WARNING====
* {{api|CheckButton:GetChecked|t=w}}
In patch 1.11 it seems like this method was changed so that it no longer works when passing '''nil''' as argument. I have tested that it works as intended when passing '''true''' and '''false'''.
 
That's not really correct. Passing "nil" will still uncheck the button, but passing *no* argument (although it should end up being nil for LUA) will enable it, also passing a table ({...}) will now check the button. [[User:Watchout|watchout]] 12:43, 29 June 2006 (EDT)
 
Yep, you're right watchout.  Also, I think this behavior was changed in 1.11.1, as it was fine right after 1.11. [[Krellmax]] 14:34, 29 June 2006 (MDT)

Latest revision as of 04:45, 15 August 2023

Widget API ← CheckButton < SetChecked

Sets the checked status of a CheckButton frame.

CheckButton:SetChecked(State);

Parameters[edit]

Arguments[edit]

state
boolean - 'true' sets the button state to checked. Default is 'false'.

Returns[edit]

none

Examples[edit]

CheckButton:SetChecked(true)

Button is checked

CheckButton:SetChecked(false)
CheckButton:SetChecked(0)
CheckButton:SetChecked(nil)
CheckButton:SetChecked()
CheckButton:SetChecked({1,2,3})
CheckButton:SetChecked("true")

Button is unchecked

Notes[edit]

  • Passing "nil" will uncheck the button, but passing *no* argument (although it should end up being nil for Lua) will enable it, also passing a table ({...}) will now check the button.
  • As of WoW 6.0 both GetChecked() and SetChecked() use Lua boolean values only. Passing value other than Lua boolean 'true' is the same as passing 'false', and GetChecked() will only return true or false. Prior to 6.0.2 values such as true, 1, -2397, {1,2,3}, "foo" would all set state as checked. Values such as false, 0, nil would set state as not checked.

See also[edit]