From 65df5b35d1cbe2d8673cbeaafa1ff34e9e58d321 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Fri, 24 Mar 2023 20:48:09 +0100 Subject: [PATCH] Add getHoveredTabName --- Sources/zui/Zui.hx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sources/zui/Zui.hx b/Sources/zui/Zui.hx index d2b35510..6199ea7e 100644 --- a/Sources/zui/Zui.hx +++ b/Sources/zui/Zui.hx @@ -40,6 +40,11 @@ class Zui { public var windowBorderBottom = 0; public var windowBorderLeft = 0; public var windowBorderRight = 0; + var hoveredTabName = ""; + var hoveredTabX = 0.0; + var hoveredTabY = 0.0; + var hoveredTabW = 0.0; + var hoveredTabH = 0.0; var highlightFullRow = false; public static var current: Zui = null; public static var onBorderHover: Handle->Int->Void = null; // Mouse over window border, use for resizing @@ -684,6 +689,14 @@ class Zui { } } + if (getInputInRect(_windowX, _windowY, _windowW, _windowH)) { + hoveredTabName = tabNames[tabHandle.position]; + hoveredTabX = _windowX; + hoveredTabY = _windowY; + hoveredTabW = _windowW; + hoveredTabH = _windowH; + } + _x = 0; // Restore positions _y = origy; _w = Std.int(!currentWindow.scrollEnabled ? _windowW : _windowW - SCROLL_W()); @@ -1790,6 +1803,11 @@ class Zui { inputY >= y * scale && inputY < (y + h) * scale; } + // Useful for drag and drop operations + public function getHoveredTabName(): String { + return getInputInRect(hoveredTabX, hoveredTabY, hoveredTabW, hoveredTabH) ? hoveredTabName : ""; + } + public function onMouseDown(button: Int, x: Int, y: Int) { // Input events if (penInUse) return; button == 0 ? inputStarted = true : inputStartedR = true;