DgsGetPosition: Difference between revisions
Jump to navigation
Jump to search
m (Thisdp moved page Dgs/DgsGetPosition to DgsGetPosition over redirect) |
No edit summary |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float, float dgsGetPosition ( element dgsElement, bool relative [, bool | float, float dgsGetPosition ( element dgsElement, bool relative [, bool isRelativeToScreen = false ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{DGS/OOP| | |||
Note = The variable is a conjunction: <br><code>position.x</code> (get X position), <code>position.y</code> (get Y position) and <code>position.relative</code> (get Relative property)| | |||
Method = DGSElement:'''getPosition'''| | |||
Variable = position| | |||
Counterpart = dgsSetPosition | |||
}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''dgsElement:''' The dgs element of which you wish to retrieve the position. | ||
*'''relative:''' | *'''relative:''' This is whether sizes and positioning are relative. If this is true, then all x,y,width,height floats must be between 0 and 1, representing sizes relative to the parent. | ||
*''' | |||
===Optional Arguments=== | |||
*'''isRelativeToScreen''' A boolean representing whether the position is relative to the screen rather than the parent. | |||
===Returns=== | ===Returns=== | ||
Line 43: | Line 51: | ||
==See Also== | ==See Also== | ||
{{ | |||
===<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>=== | |||
{{DGS General Functions}} | |||
===<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>=== | |||
{{DGS Events/General}} |
Latest revision as of 04:55, 5 November 2023
This function allows retrieval of a DGS element's current position, relative to its parent.
Syntax
float, float dgsGetPosition ( element dgsElement, bool relative [, bool isRelativeToScreen = false ] )
DGS OOP Syntax Help! I don't understand this!
- Note: The variable is a conjunction:
position.x
(get X position),position.y
(get Y position) andposition.relative
(get Relative property) - Method: DGSElement:getPosition(...)
- Variable: .position
- Counterpart: dgsSetPosition
Required Arguments
- dgsElement: The dgs element of which you wish to retrieve the position.
- relative: This is whether sizes and positioning are relative. If this is true, then all x,y,width,height floats must be between 0 and 1, representing sizes relative to the parent.
Optional Arguments
- isRelativeToScreen A boolean representing whether the position is relative to the screen rather than the parent.
Returns
Returns floats representing the x and y position of the element, or false if the position could not be retrieved.
Example
This example checks which corner a dgs element exists in
DGS = exports.dgs function positionCheck ( dgsElement ) local x,y = DGS:dgsGetPosition ( dgsElement, true ) --get the position local position --define the position if ( x == 0.5 ) and ( y == 0.5 ) then --if its bang in the middle position = "middle" --set position to middle elseif ( x > 0.5 ) and ( y > 0.5 ) then --if its in the right bottom position = "right-bottom" elseif ( x < 0.5 ) and ( y < 0.5 ) then --if its in the left top position = "left-top" elseif ( x < 0.5 ) and ( y > 0.5 ) then --if its in the left bottom position = "left-bottom" elseif ( x > 0.5 ) and ( y < 0.5 ) then --if its in the right top position = "right-top" else --if it couldnt be retrieved position = "unknown" end --announce this into the chatbox outputChatBox ( "The dgs element's position is "..position.."!" ) end
See Also
General Functions
- dgsGetPosition
- dgsSetPosition
- dgsSetParent
- dgsGetParent
- dgsGetChild
- dgsGetChildren
- dgsGetSize
- dgsSetSize
- dgsGetType
- dgsSetLayer
- dgsGetLayer
- dgsSetCurrentLayerIndex
- dgsGetCurrentLayerIndex
- dgsGetLayerElements
- dgsGetProperty
- dgsSetProperty
- dgsSetPropertyInherit
- dgsGetProperties
- dgsSetProperties
- dgsGetVisible
- dgsSetVisible
- dgsGetEnabled
- dgsSetEnabled
- dgsGetPositionAlignment
- dgsSetPositionAlignment
- dgsGetAlpha
- dgsSetAlpha
- dgsGetFont
- dgsSetFont
- dgsGetText
- dgsSetText
- dgsGetPostGUI
- dgsSetPostGUI
- dgsGetInputEnabled
- dgsSetInputEnabled
- dgsGetInputMode
- dgsSetInputMode
- dgsAttachToAutoDestroy
- dgsDetachFromAutoDestroy
- dgsFocus
- dgsBlur
- dgsCreateFont
- dgsBringToFront
- dgsMoveToBack
- dgsGetScreenSize
- dgsGetCursorPosition
- dgsGetMouseEnterGUI
- dgsGetMouseLeaveGUI
- dgsIsMouseWithinGUI
- dgsSetSystemFont
- dgsGetSystemFont
- dgsGetElementsInLayer
- dgsGetElementsFromResource
- dgsGetFocusedGUI
- dgsImportFunction
- dgsImportOOPClass
- dgsG2DLoadHooker
- dgsSetRenderSetting
- dgsGetRenderSetting
- dgsSimulateClick
- dgsGetRootElement
- dgsAddMoveHandler
- dgsRemoveMoveHandler
- dgsIsMoveHandled
- dgsAddSizeHandler
- dgsRemoveSizeHandler
- dgsIsSizeHandled
- dgsAttachElements
- dgsDetachElements
- dgsElementIsAttached
- dgsAddPropertyListener
- dgsRemovePropertyListener
- dgsGetListenedProperties
- dgsSetMultiClickInterval
- dgsGetMultiClickInterval
- dgsSetMouseStayDelay
- dgsGetMouseStayDelay
- dgsCenterElement
- dgsSetElementKeeperEnabled
- dgsGetElementKeeperEnabled
- dgsSetClickingSound
- dgsGetClickingSound
- dgsSetClickingSoundVolume
- dgsGetClickingSoundVolume
General Events
- onDgsBlur
- onDgsCreate
- onDgsCursorTypeChange
- onDgsCursorStateChange
- onDgsDestroy
- onDgsElementRender
- onDgsElementMove
- onDgsElementSize
- onDgsElementEnter
- onDgsElementLeave
- onDgsFocus
- onDgsKey
- onDgsPositionChange
- onDgsPreRender
- onDgsRender
- onDgsElementScroll
- onDgsSizeChange
- onDgsTextChange
- onDgsWindowClose
- onDgsPropertyChange