Cafu Engine
ComponentChoiceT Class Reference

This components add the behaviour of a choice field to its window. More...

Inheritance diagram for ComponentChoiceT:

Public Member Functions

 set (string var_name, any)
 An override of the base class method that also calls Sync(). More...
 
string GetSelItem ()
 Returns the currently selected item (or nil if no item is selected). More...
 
- Public Member Functions inherited from ComponentBaseT
any get (string var_name)
 Returns the value of an attribute (a member variable) of this class. More...
 
 set (string var_name, any new_value)
 Sets an attribute (a member variable) of this class to a new value. More...
 
string GetExtraMessage (string var_name)
 Returns the result of VarBaseT::GetExtraMessage() for the given member variable. More...
 
 interpolate (string var_name, number start_value, number end_value, number time)
 Schedules a value for interpolation between a start and end value over a given period of time. More...
 

Public Attributes

table Choices
 The list of available choices. More...
 
number Selection
 The index number of the currently selected choice, where 1 corresponds to the first choice (as per Lua convention). More...
 

Event Handlers (Callbacks)

See the Event Handlers (Callbacks) overview page for additional information about the methods in this group.

 OnSelectionChanged ()
 This method is called when the choice's selection has changed. More...
 

Detailed Description

This components add the behaviour of a choice field to its window.

It requires that the window also has a text component, whose value it updates according to user interaction to one of the available choices.

Note that the variables of this class (also referred to as "Public Attributes" or "Member Data") must be used with the get() and set() methods at this time – see get() and set() for details.

If you would like to create a new component of this type explicitly (those defined in the CaWE GUI Editor are instantiated automatically), use GuiT::new():

local comp = gui:new("ComponentChoiceT")
Implementing C++ Class:
cf::GuiSys::ComponentChoiceT

Member Function Documentation

string GetSelItem ( )

Returns the currently selected item (or nil if no item is selected).

OnSelectionChanged ( )

This method is called when the choice's selection has changed.

The selection may have changed as the result of a mouse click or a key press, whereas calling self:set("Selection", ...) does not trigger this event.

Use self:GetSelItem() or self:get("Selection") in order to learn which item has recently been selected.

set ( string  var_name,
any   
)

An override of the base class method that also calls Sync().

Member Data Documentation

table Choices

The list of available choices.

Related C++ type:
ArrayT<std::string>
number Selection

The index number of the currently selected choice, where 1 corresponds to the first choice (as per Lua convention).

Use 0 for "no selection".

Related C++ type:
unsigned int