UiGetRelativePos — Dennispedia

UiGetRelativePos

Get the position of the "cursor" (the origin of UI elements moved by UiTranslate, not the mouse cursor), taking scale into account.

For some reason, this function returns no values if the UI stack is empty.

Like all UI functions, this function will only exist if draw is defined before init is called.

This function is not officially documented.

Arguments

None.

Return values

  1. number or no value: X coordinate, or no value if UI stack is empty
  2. number or no value: Y coordinate, or no value if UI stack is empty

Example usage

function draw()
	UiPush()
		UiTranslate(100, 200)
		UiScale(0.5, 0.25)
		UiTranslate(20, 40)
		local x, y = UiGetRelativePos()
		DebugWatch("x", x) -- 110
		DebugWatch("y", y) -- 210
	UiPop()
end