Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ColorPickButtonElement
- ConstructionScreen
- ContextActionDisplay
- ControlBarDisplay
- DialogElement
- DynamicFadedBitmapElement
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GameInfoDisplayMobile
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiTopDownCursor
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDSliderElement
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InfoDisplay
- InfoHUDBox
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputGlyphElementUI
- InputHelpDisplay
- KeyValueInfoHUDBox
- ListElement
- ListItemElement
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PictureElement
- PlatformIconElement
- PlayerControlPadDisplay
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- ScrollingLayoutElement
- SettingsModel
- SideNotification
- SideNotificationMobile
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- SpeedSliderDisplay
- StatusBar
- SteeringSliderDisplay
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TerrainLayerElement
- TextBackdropElement
- TextElement
- TextInputElement
- ThreePartBitmapElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VariableWorkWidthHUDExten...
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- WardrobeScreen
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
ListItemElement
DescriptionList item element to be used and laid out by ListElement and TableElement. Used layers: "image" for a background image.Parent
BitmapElementXML Configuration Parameters
GuiElement#allowSelected | bool [optional] If false, this element cannot be selected, only focused or activated. |
GuiElement#autoSelectChildren | bool [optional] If true, focus and selection states are propagated with priority to child elements. Only if no child element can be focused or selected will this element receive that state itself. |
GuiElement#onFocus | callback [optional] onFocus(element) Called when the cursor enters the borders of this element. Receives this element as an argument. |
GuiElement#onLeave | callback [optional] onLeave(element) Called when the cursor leaves the borders of this element. Receives this element as an argument. |
GuiElement#onClick | callback [optional] onClick(element) Called then this element is clicked / activated. Receives this element as an argument. |
Functions
copyAttributes
DescriptionDefinitioncopyAttributes()Code
73 | function ListItemElement:copyAttributes(src) |
74 | ListItemElement:superClass().copyAttributes(self, src) |
75 | |
76 | self.allowSelected = src.allowSelected |
77 | self.isSectionHeader = src.isSectionHeader |
78 | self.autoSelectChildren = src.autoSelectChildren |
79 | self.hideSelection = src.hideSelection |
80 | |
81 | self.backgroundColor = src.backgroundColor |
82 | self.alternateBackgroundColor = src.alternateBackgroundColor |
83 | self.alternateBackgroundLoaded = src.alternateBackgroundLoaded |
84 | |
85 | self.onLeaveCallback = src.onLeaveCallback |
86 | self.onFocusCallback = src.onFocusCallback |
87 | self.onClickCallback = src.onClickCallback |
88 | end |
getFocusTarget
DescriptionGet the actual focus target, in case a child or parent element needs to be targeted instead. Override from BitmapElement: Only focuses children if #autoSelectChildren is trueDefinition
getFocusTarget(incomingDirection (Optional), moveDirection (Optional))Arguments
incomingDirection | (Optional) | If specified, may return different targets for different incoming directions. |
moveDirection | (Optional) | Actual movement direction per input. This is the opposing direction of incomingDirection. |
GuiElement | Actual | element to focus. |
201 | function ListItemElement:getFocusTarget(incomingDirection, moveDirection) |
202 | if self.autoSelectChildren then |
203 | return ListItemElement:superClass().getFocusTarget(self, incomingDirection, moveDirection) |
204 | else |
205 | return self |
206 | end |
207 | end |
getIsSelected
DescriptionDefinitiongetIsSelected()Code
92 | function ListItemElement:getIsSelected() |
93 | if self:getOverlayState() == GuiOverlay.STATE_SELECTED then |
94 | return true |
95 | else |
96 | return ListItemElement:superClass().getIsSelected(self) |
97 | end |
98 | end |
loadFromXML
DescriptionDefinitionloadFromXML()Code
42 | function ListItemElement:loadFromXML(xmlFile, key) |
43 | ListItemElement:superClass().loadFromXML(self, xmlFile, key) |
44 | |
45 | self.allowSelected = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowSelected"), self.allowSelected) |
46 | self.autoSelectChildren = Utils.getNoNil(getXMLBool(xmlFile, key.."#autoSelectChildren"), self.autoSelectChildren) |
47 | self.hideSelection = Utils.getNoNil(getXMLBool(xmlFile, key.."#hideSelection"), self.hideSelection) |
48 | |
49 | self:addCallback(xmlFile, key.."#onFocus", "onFocusCallback") -- TODO: change to onHighlight() |
50 | self:addCallback(xmlFile, key.."#onLeave", "onLeaveCallback") |
51 | self:addCallback(xmlFile, key.."#onClick", "onClickCallback") |
52 | end |
loadProfile
DescriptionDefinitionloadProfile()Code
56 | function ListItemElement:loadProfile(profile, applyProfile) |
57 | ListItemElement:superClass().loadProfile(self, profile, applyProfile) |
58 | |
59 | self.allowSelected = profile:getBool("allowSelected", self.allowSelected) |
60 | self.autoSelectChildren = profile:getBool("autoSelectChildren", self.autoSelectChildren) |
61 | self.hideSelection = profile:getBool("hideSelection", self.hideSelection) |
62 | |
63 | if not self.alternateBackgroundLoaded then |
64 | self.backgroundColor = table.copy(GuiOverlay.getOverlayColor(self.overlay, GuiOverlay.STATE_NORMAL)) |
65 | self.alternateBackgroundColor = GuiUtils.getColorArray(profile:getValue("alternateBackgroundColor")) |
66 | self.alternateBackgroundLoaded = true |
67 | end |
68 | |
69 | end |
mouseEvent
DescriptionDefinitionmouseEvent()Code
138 | function ListItemElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) |
139 | if self:getIsVisible() then |
140 | if ListItemElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) then |
141 | eventUsed = true |
142 | end |
143 | |
144 | if not eventUsed and GuiUtils.checkOverlayOverlap(posX, posY, self.absPosition[1], self.absPosition[2], self.absSize[1], self.absSize[2]) then |
145 | if not isDown and not isUp then |
146 | if self:getOverlayState() ~= GuiOverlay.STATE_SELECTED and self.handleFocus then |
147 | FocusManager:setHighlight(self) |
148 | end |
149 | |
150 | if not self.mouseEntered then |
151 | self.mouseEntered = true |
152 | if self.handleFocus then |
153 | self:raiseCallback("onFocusCallback", self) |
154 | end |
155 | end |
156 | end |
157 | |
158 | if isDown then |
159 | if button == Input.MOUSE_BUTTON_LEFT then |
160 | self.mouseDown = true |
161 | end |
162 | end |
163 | |
164 | if isUp and button == Input.MOUSE_BUTTON_LEFT and self.mouseDown then |
165 | self.mouseDown = false |
166 | self:raiseCallback("onClickCallback", self) |
167 | end |
168 | else |
169 | if self.mouseEntered then |
170 | self.mouseEntered = false |
171 | if self.handleFocus then |
172 | self:raiseCallback("onLeaveCallback", self) |
173 | end |
174 | end |
175 | |
176 | self.mouseDown = false |
177 | if not self.focusActive and self.handleFocus then |
178 | if self:getOverlayState() ~= GuiOverlay.STATE_SELECTED then |
179 | FocusManager:unsetHighlight(self) |
180 | end |
181 | end |
182 | end |
183 | end |
184 | |
185 | return eventUsed |
186 | end |
new
DescriptionDefinitionnew()Code
24 | function ListItemElement.new(target, custom_mt) |
25 | local self = BitmapElement.new(target, custom_mt or ListItemElement_mt) |
26 | |
27 | self.mouseEntered = false |
28 | self.allowSelected = true |
29 | self.autoSelectChildren = false |
30 | self.handleFocus = false |
31 | self.hideSelection = false |
32 | |
33 | self.alternateBackgroundColor = nil |
34 | |
35 | self.attributes = {} |
36 | |
37 | return self |
38 | end |
onClose
DescriptionDefinitiononClose()Code
102 | function ListItemElement:onClose() |
103 | ListItemElement:superClass().onClose(self) |
104 | self:reset() |
105 | end |
setSelected
DescriptionDefinitionsetSelected()Code
118 | function ListItemElement:setSelected(selected) |
119 | if selected and not self.hideSelection then |
120 | if self.allowSelected then |
121 | self:setOverlayState(GuiOverlay.STATE_SELECTED) |
122 | else |
123 | self:setOverlayState(GuiOverlay.STATE_FOCUSED) |
124 | end |
125 | else |
126 | if self:getOverlayState() ~= GuiOverlay.STATE_HIGHLIGHTED then |
127 | if self.disabled then |
128 | self:setOverlayState(GuiOverlay.STATE_DISABLED) |
129 | else |
130 | self:setOverlayState(GuiOverlay.STATE_NORMAL) |
131 | end |
132 | end |
133 | end |
134 | end |