Drag[en]gine Script Module DragonScript  1.23
Dragengine.Gui.OptionGroupModel Class Reference

Option group model. More...

Inheritance diagram for Dragengine.Gui.OptionGroupModel:
Dragengine.Gui.DefaultToggleModel Dragengine.Gui.ToggleModel

Public Member Functions

int getIndexElement ()
 List model element index or -1 if lost. More...
 
ListModel getListModel ()
 List model. More...
 
OptionGroupModel new (ListModel listModel, int indexElement)
 Create option group model linked to ListModel element at index. More...
 
void setIndexElement (int indexElement)
 Set list model element index or -1 if lost. More...
 
void setToggled (bool toggled)
 Set toggled state. More...
 
- Public Member Functions inherited from Dragengine.Gui.DefaultToggleModel
void addListener (ToggleModelListener listener)
 Add listener. More...
 
bool getToggled ()
 Get toggled state. More...
 
DefaultToggleModel new ()
 Create toggle model with false toggled state. More...
 
DefaultToggleModel new (bool toggled)
 Create toggle model. More...
 
void removeListener (ToggleModelListener listener)
 Remove listener. More...
 

Static Public Member Functions

static OptionGroupModel newFor (ListModel listModel, Object element)
 Create option group model linked to ListModel element. More...
 

Detailed Description

Option group model.

Version
1.11

Links a ToggleModel to a ListModel entry. If the list model entry is selected the toggle model is toggled otherwise untoggled. If the toggle model is toggled while untoggled the respective element in the list model is selected.

Example of how to use this model:

class MyClass
enum MyEnum
option1
option2
option3
end
private var DefaultListModel modelOptions
private func createUI(Container container)
// create model containing the options
modelOptions = DefaultListModel.new(MyEnum.all())
modelOptions.setSelectedElement(MyEnum.option2)
// create and add option boxes for each option. the toggled state of the
// option boxes is synchronized with the list model selection
container.addWidget(OptionBox.new(OptionGroupModel.newFor(modelOptions, MyEnum.option1), "Option 1"))
container.addWidget(OptionBox.new(OptionGroupModel.newFor(modelOptions, MyEnum.option2), "Option 2"))
container.addWidget(OptionBox.new(OptionGroupModel.newFor(modelOptions, MyEnum.option3), "Option 3"))
// you could also use direct indices instead of looking up list elements.
// looking up list elements is safer. using indices can be useful if you
// want to add options by iterating of the list model elements
//
// container.addWidget(OptionBox.new(OptionGroupModel.new(modelOptions, 0), "Option 1"))
// ...
// you can use this class for all instance accepting toggle models.
// for example to add an option menu entry you can do this:
//
// menuPanel.addWidget(MenuItemOption.new(OptionGroupModel.new(modelOptions, 0), "Option 1"))
end
end

Member Function Documentation

◆ getIndexElement()

int Dragengine.Gui.OptionGroupModel.getIndexElement ( )

List model element index or -1 if lost.

◆ getListModel()

ListModel Dragengine.Gui.OptionGroupModel.getListModel ( )

List model.

◆ new()

OptionGroupModel Dragengine.Gui.OptionGroupModel.new ( ListModel  listModel,
int  indexElement 
)

Create option group model linked to ListModel element at index.

◆ newFor()

static OptionGroupModel Dragengine.Gui.OptionGroupModel.newFor ( ListModel  listModel,
Object  element 
)
static

Create option group model linked to ListModel element.

◆ setIndexElement()

void Dragengine.Gui.OptionGroupModel.setIndexElement ( int  indexElement)

Set list model element index or -1 if lost.

Warning
For internal use only.

◆ setToggled()

void Dragengine.Gui.OptionGroupModel.setToggled ( bool  toggled)

Set toggled state.

Reimplemented from Dragengine.Gui.DefaultToggleModel.


The documentation for this class was generated from the following file: