UDN
Search public documentation:
CLIKCheckBox
日本語訳
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
中国翻译
한국어
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
How to get and set a check box value
Overview
This tutorial shows you how to set or get a value from a check box.
Getting a checkbox's value
The following UnrealScript will allow you to get the value of a checkbox, assuming your checkbox has an instance name in Flash of 'aCheckBox' and assuming you're using a CLIK widget for that checkbox:
var GFxClikWidget MyCheckBox; var bool MyOption; event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget) { switch(WidgetName) { case ('aCheckBox'): MyCheckBox = GFxClikWidget(Widget); if (MyCheckBox != None) { MyCheckBox.AddEventListener('CLIK_select', OnMyCheckBoxChange); } break; default: break; } return true; } function OnMyCheckBoxChange(GFxClikWidget.EventData ev) { MyOption = MyCheckBox.GetBool("_selected"); `log("aCheckBox has been set to: "@MyOption); } defaultproperties { WidgetBindings.Add((WidgetName="aCheckBox",WidgetClass=class'GFxClikWidget')) }
MyOption = MyCheckBox.GetBool("_selected");
Setting a Checkbox's Value
To set a checkbox from UnrealScript:
MyCheckBox.SetBool("selected", true); // or false
SetMyCheckBox(true); // true or false function SetMyCheckBox(bool b) { ActionScriptVoid("SetMyCheckBox"); // passes the boolean value stored in 'b' to the AS function SetMyCheckBox }
function SetMyCheckBox(checked:Boolean) { aCheckBox.selected = checked; }