Skip to content

Commit

Permalink
Add getHoveredTabName
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Mar 24, 2023
1 parent d7983f7 commit 65df5b3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/zui/Zui.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 65df5b3

Please sign in to comment.