GuiGetPosition: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (→See Also) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | |||
This | This function allows retrieval of a GUI element's current position, relative to its parent. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float float guiGetPosition ( element | float, float guiGetPosition ( element guiElement, bool relative ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[GUI widgets|GuiElement]]:getPosition|position|guiSetPosition}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''guiElement:''' The gui element of which you wish to retrieve the position. | |||
*''' | *'''relative:''' A boolean representing whether the position should be relative to the element's parent width, or the number of offset pixels from the parent's origin. | ||
===Returns=== | |||
=== | Returns floats representing the ''x'' and ''y'' position of the element, or false if the position could not be retrieved. | ||
==Example== | ==Example== | ||
This example checks which corner a gui element exists in | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function positionCheck ( guiElement ) | ||
local x,y = guiGetPosition ( guiElement, 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 gui element's position is "..position.."!" ) | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{GUI_functions}} | |||
{{ | {{GUI_events}} | ||
Latest revision as of 17:16, 21 November 2018
This function allows retrieval of a GUI element's current position, relative to its parent.
Syntax
float, float guiGetPosition ( element guiElement, bool relative )
OOP Syntax Help! I don't understand this!
- Method: GuiElement:getPosition(...)
- Variable: .position
- Counterpart: guiSetPosition
Required Arguments
- guiElement: The gui element of which you wish to retrieve the position.
- relative: A boolean representing whether the position should be relative to the element's parent width, or the number of offset pixels from the parent's origin.
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 gui element exists in
function positionCheck ( guiElement ) local x,y = guiGetPosition ( guiElement, 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 gui element's position is "..position.."!" ) end
See Also
General functions
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign
Windows
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel