Widget handler: OnDoubleClick

From AddOn Studio
Jump to navigation Jump to search

Widget handlers < OnDoubleClick

Description[edit]

The OnDoubleClick handler is called when a UI element is double-clicked with the mouse.

Arguments[edit]

self - the button frame being clicked

button - a string representing the button that was clicked. Can be any of the following:

  • LeftButton
  • RightButton
  • MiddleButton
  • Button4
  • Button5

According to how the UI element is setup with API_Button_RegisterForClicks

Notes[edit]

  • Only Button type frames have an OnDoubleClick script, but you can fake it like this:
-- Known issue. Since, time() returns an integer (not a floating point number),
-- the threshold for double-clicking ranges from 0.0000000000001 to 1 second.
-- I tried using GetTime(), but I couldn't seem to get it to work.
frame.timer = 0
frame:SetScript("OnMouseUp", function(...)
    if this.timer < time() then
        this.startTimer = false
    end
    if this.timer == time() and this.startTimer then
        this.startTimer = false

        DoStuff()
    else
        this.startTimer = true
        this.timer = time()
    end
end)