CheckListΒΆ
class CheckList
The base class for check list widgets
Hierarchy
class CheckList < class Window
Children classes : class ToggleCheckList
Members
| create | ( ) | Create a CheckList widget |
| createitemwindow | ( ) | Init the item window |
| fill | ( ) | Fill the widget with all lines |
| getitems | ( ) | Callback for when the widget needs the list of items |
| getitemstate | ( ) | Callback for when the widget needs the state of an item of the list. |
| itemclicked | ( ) | Callback for when the an item of the list was clicked. |
| update | ( ) | Update the list state |
| updateitemwindow | ( ) | Update the item window |
Inherited from class Window
| destroy | ( ) | Destroy the window and all its children windows |
| setx | (
|
Set the X window placement |
| sety | (
|
Set the Y window placement |
| setw | (
|
Set the window width |
| seth | (
|
Set the window height |
| getx | ( ) | Get the window X coordinate in the parent space |
| gety | ( ) | Get the window Y coordinate in the parent space |
| getw | ( ) | Get the window width |
| geth | ( ) | Get the window height |
| hide | ( ) | Hide the window |
| show | ( ) | Show the window |
| disable | ( ) | Disable the window |
| enable | ( ) | Enable the window |
| getnodepath | ( ) | Returns the edited node path (is nil if the method is not supported) |
| setnodepath | (
|
|
| addtracker | (
|
Add a tracker to this window. A tracker receives notification when the tracked window is invalidated or destroyed. A tracker may implement onTrackedDestroyed and onTrackedInvalidated to get notifications on such events |
| removetracker | (
|
Remove a tracker of this window. |
| setcolor | (
|
Change the window color, see also ui.color function |
| getparent | (
|
Get the first parent window of given class (immediate parent if no class is provided) |
| settopmost | ( ) | Set the window as top most in children order |
| getchild | (
|
Get a child window |
| getcontainer | ( ) | Get the main container of a window |
| settitle | (
|
Change the window title |
| setfocus | ( ) | Set the focus to the window |
| getroot | ( ) | Return the root window of this window |
Documentation
Init the item window
Fill the widget with all lines
Callback for when the widget needs the list of items
You must implement this method, which in turn returns the items contained:
-- Create a title window
local title = ui.titlewindow ()
title:settitle ("Test")
title:setpos { w=200, h=200 }
-- Create a check list in the title window
local checklist = CheckList.create ("list", title)
function checklist:getitems ()
-- Return the list of items
return { "One", "Two", "Three" }
end
checklist:fill ()
checklist:setpos { x=0, y=0, w=ui.full }
Alternatively, the default implementation will use the Items field in the widget if present.
items The list of items in the list
Callback for when the widget needs the state of an item of the list.
You must implement this method, which in turn returns the state of the given item. The passed item is the same that is returned by the getitems method:
-- Create a title window
local title = ui.titlewindow ()
title:settitle ("Test")
title:setpos { w=200, h=200 }
-- Create a check list in the title window
local checklist = CheckList.create ("list", title)
checklist.Items = { "One", "Two", "Three" }
function checklist:getitemstate (item)
-- Return the state of an item
return item == "One" and CheckList.ItemDefault or
item == "Two" and CheckList.ItemChecked or
CheckList.ItemUnchecked
end
checklist:fill ()
checklist:setpos { x=0, y=0, w=ui.full }
The possible item states are:
- CheckList.ItemDefault: the item is displayed using the default style
- CheckList.ItemChecked: the item is displayed using the checked style
- CheckList.ItemUnchecked: the item is displayed using the not checked style
- CheckList.ItemHighlight: the item is displayed using the highlight style
state The current item state
Callback for when the an item of the list was clicked.
You must implement this method to react to the user clicking a list item:
-- Create a title window
local title = ui.titlewindow ()
title:settitle ("Test")
title:setpos { w=200, h=200 }
-- Create a check list in the title window
local checklist = CheckList.create ("list", title)
-- init items states
checklist.State = { One=true, Two=false, Three=true }
checklist.Items = { "One", "Two", "Three" }
function checklist:getitemstate (item)
-- Return the state of an item
return self.State[item] and CheckList.ItemChecked or CheckList.ItemDefault
end
function checklist:itemclicked (item)
-- Invert the state of the clicked item
self.State[item] = not self.State[item]
end
checklist:fill ()
checklist:setpos { x=0, y=0, w=ui.full }
Update the list state
Update the item window