Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- JointConstructor:setActors
- JointConstructor:setJointTransforms
- addDifferential
- addForce
- addImpulse
- addTorque
- addTorqueImpulse
- addVehicleLink
- computeWheelShapeTireForces
- createCCT
- createWheelShape
- getAngularDamping
- getAngularVelocity
- getCCTCollisionFlags
- getCenterOfMass
- getCollisionMask
- getDensity
- getLinearDamping
- getLinearVelocity
- getMass
- getMotorRotationSpeed
- getRigidBodyType
- getVelocityAtLocalPos
- getVelocityAtWorldPos
- getVolume
- getWheelShapeAxleSpeed
- getWheelShapeContactForce
- getWheelShapeContactNormal
- getWheelShapeContactObject
- getWheelShapeContactPoint
- getWheelShapePosition
- getWheelShapeSlip
- moveCCT
- overlapBox
- overlapSphere
- raycastAll
- raycastClosest
- removeCCT
- setAngularDamping
- setAngularVelocity
- setCenterOfMass
- setCollisionMask
- setFrictionVelocity
- setJointDrive
- setLinearDamping
- setLinearVelocity
- setMass
- setRigidBodyType
- setSolverIterationCount
- setWheelShapeForcePoint
- setWheelShapeProps
- setWheelShapeTireFriction
- simulatePhysics
- simulatePhysicsTimeScale
- updateDifferential
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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#allowFocus | bool [optional] If false, this element cannot be focused |
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
67 | function ListItemElement:copyAttributes(src) |
68 | ListItemElement:superClass().copyAttributes(self, src) |
69 | |
70 | self.allowSelected = src.allowSelected |
71 | self.allowFocus = src.allowFocus |
72 | self.autoSelectChildren = src.autoSelectChildren |
73 | self.onLeaveCallback = src.onLeaveCallback |
74 | self.onFocusCallback = src.onFocusCallback |
75 | self.onClickCallback = src.onClickCallback |
76 | 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. |
169 | function ListItemElement:getFocusTarget(incomingDirection, moveDirection) |
170 | if self.autoSelectChildren then |
171 | return ListItemElement:superClass().getFocusTarget(self, incomingDirection, moveDirection) |
172 | else |
173 | return self |
174 | end |
175 | end |
getIsSelected
DescriptionDefinitiongetIsSelected()Code
80 | function ListItemElement:getIsSelected() |
81 | if self:getOverlayState() == GuiOverlay.STATE_SELECTED then |
82 | return true |
83 | else |
84 | return ListItemElement:superClass().getIsSelected(self) |
85 | end |
86 | end |
loadFromXML
DescriptionDefinitionloadFromXML()Code
43 | function ListItemElement:loadFromXML(xmlFile, key) |
44 | ListItemElement:superClass().loadFromXML(self, xmlFile, key) |
45 | |
46 | self.allowSelected = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowSelected"), self.allowSelected) |
47 | self.allowFocus = Utils.getNoNil(getXMLBool(xmlFile, key.."#allowFocus"), self.allowFocus) |
48 | self.autoSelectChildren = Utils.getNoNil(getXMLBool(xmlFile, key.."#autoSelectChildren"), self.autoSelectChildren) |
49 | |
50 | self:addCallback(xmlFile, key.."#onFocus", "onFocusCallback") -- TODO: change to onHighlight() |
51 | self:addCallback(xmlFile, key.."#onLeave", "onLeaveCallback") |
52 | self:addCallback(xmlFile, key.."#onClick", "onClickCallback") |
53 | end |
loadProfile
DescriptionDefinitionloadProfile()Code
57 | function ListItemElement:loadProfile(profile, applyProfile) |
58 | ListItemElement:superClass().loadProfile(self, profile, applyProfile) |
59 | |
60 | self.allowSelected = profile:getBool("allowSelected", self.allowSelected) |
61 | self.allowFocus = profile:getBool("allowFocus", self.allowFocus) |
62 | self.autoSelectChildren = profile:getBool("autoSelectChildren", self.autoSelectChildren) |
63 | end |
mouseEvent
DescriptionDefinitionmouseEvent()Code
113 | function ListItemElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) |
114 | if self:getIsVisible() then |
115 | if ListItemElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) then |
116 | eventUsed = true |
117 | end |
118 | |
119 | if not eventUsed and GuiUtils.checkOverlayOverlap(posX, posY, self.absPosition[1], self.absPosition[2], self.size[1], self.size[2]) then |
120 | if not isDown and not isUp then |
121 | if self:getOverlayState() ~= GuiOverlay.STATE_SELECTED and self.handleFocus then |
122 | FocusManager:setHighlight(self) |
123 | end |
124 | |
125 | if not self.mouseEntered then |
126 | self.mouseEntered = true |
127 | if self.handleFocus then |
128 | self:raiseCallback("onFocusCallback", self) |
129 | end |
130 | end |
131 | end |
132 | |
133 | if isDown then |
134 | if button == Input.MOUSE_BUTTON_LEFT then |
135 | self.mouseDown = true |
136 | end |
137 | end |
138 | |
139 | if isUp and button == Input.MOUSE_BUTTON_LEFT and self.mouseDown then |
140 | self.mouseDown = false |
141 | self:raiseCallback("onClickCallback", self) |
142 | end |
143 | else |
144 | if self.mouseEntered then |
145 | self.mouseEntered = false |
146 | if self.handleFocus then |
147 | self:raiseCallback("onLeaveCallback", self) |
148 | end |
149 | end |
150 | |
151 | self.mouseDown = false |
152 | if not self.focusActive and self.handleFocus then |
153 | if self:getOverlayState() ~= GuiOverlay.STATE_SELECTED then |
154 | FocusManager:unsetHighlight(self) |
155 | end |
156 | end |
157 | end |
158 | end |
159 | |
160 | return eventUsed |
161 | end |
new
DescriptionDefinitionnew()Code
25 | function ListItemElement:new(target, custom_mt) |
26 | if custom_mt == nil then |
27 | custom_mt = ListItemElement_mt |
28 | end |
29 | |
30 | local self = BitmapElement:new(target, custom_mt) |
31 | |
32 | self.mouseEntered = false |
33 | self.allowSelected = true |
34 | self.allowFocus = true |
35 | self.autoSelectChildren = false |
36 | self.handleFocus = false |
37 | |
38 | return self |
39 | end |
onClose
DescriptionDefinitiononClose()Code
90 | function ListItemElement:onClose() |
91 | ListItemElement:superClass().onClose(self) |
92 | self:reset() |
93 | end |
setSelected
DescriptionDefinitionsetSelected()Code
97 | function ListItemElement:setSelected(selected) |
98 | if selected then |
99 | if self.allowSelected then |
100 | self:setOverlayState(GuiOverlay.STATE_SELECTED) |
101 | else |
102 | self:setOverlayState(GuiOverlay.STATE_FOCUSED) |
103 | end |
104 | else |
105 | if self:getOverlayState() ~= GuiOverlay.STATE_HIGHLIGHTED then |
106 | self:setOverlayState(GuiOverlay.STATE_NORMAL) |
107 | end |
108 | end |
109 | end |