WoW:UIHANDLER OnCursorChanged: Difference between revisions
Jump to navigation
Jump to search
(new) |
m (Move page script moved page UIHANDLER OnCursorChanged to UIHANDLER OnCursorChanged without leaving a redirect) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{widgethandler}} | {{widgethandler}}<br> | ||
== Description == | == Description == | ||
Line 13: | Line 13: | ||
== Example == | == Example == | ||
Say we have a plain textbox inside a scrollframe (inside [[UIPanelScrollFrameTemplate]]; as the only child-element, etc.), the following code will automatically move scrollframe viewport so that the cursor is inside it. | Say we have a plain textbox inside a scrollframe (inside [[UIPanelScrollFrameTemplate]]; as the only child-element, etc.), the following code will automatically move scrollframe viewport so that the cursor is inside it. (The | ||
ScrollingEdit_OnUpdate() function in UIPanelTemplates.lua does something akin to this also.) | |||
<OnCursorChanged> | <OnCursorChanged> | ||
local vs = this:GetParent():GetVerticalScroll(); | local vs = this:GetParent():GetVerticalScroll(); |
Latest revision as of 04:49, 15 August 2023
← Widget handlers < OnCursorChanged
Description[edit]
Called whenever the cursor in an edit box was moved. Note that the cursor is also moved when typing.
Arguments[edit]
- arg1
- the new horizontal (x) position of the cursor in the edit box (the first column being 0, increasing to the right)
- arg2
- the new vertical (y) position of the cursor in the edit box (the first line being 0, DEcreasing downwards)
- arg3
- unknown
- arg4
- the height of one line
Example[edit]
Say we have a plain textbox inside a scrollframe (inside UIPanelScrollFrameTemplate; as the only child-element, etc.), the following code will automatically move scrollframe viewport so that the cursor is inside it. (The ScrollingEdit_OnUpdate() function in UIPanelTemplates.lua does something akin to this also.)
<OnCursorChanged> local vs = this:GetParent():GetVerticalScroll(); local h = this:GetParent():GetHeight(); if vs+arg2 > 0 or 0 > vs+arg2-arg4+h then this:GetParent():SetVerticalScroll(arg2*-1); end </OnCursorChanged>