From e992ebe8f4269a121a321ffc3f825a75983d949e Mon Sep 17 00:00:00 2001 From: IgorTimofeev Date: Thu, 15 Jul 2021 14:01:50 +0700 Subject: [PATCH] Fixed window:focus issue --- Libraries/GUI.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 7a4fbf3a..6ad1b409 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -4304,12 +4304,8 @@ local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...) end if window ~= window.parent.children[#window.parent.children] then - window:moveToFront() + window:focus() - if window.onFocus then - window.onFocus(workspace, window, e1, e2, e3, e4, ...) - end - workspace:draw() end elseif e1 == "drag" and window.lastTouchX and not windowCheck(window, e3, e4) then @@ -4380,17 +4376,29 @@ function GUI.windowMinimize(window) window.hidden = not window.hidden end +function GUI.windowFocus(window) + GUI.focusedObject = window + window.hidden = false + window:moveToFront() + + if window.onFocus then + window.onFocus() + end +end + function GUI.window(x, y, width, height) local window = GUI.container(x, y, width, height) window.passScreenEvents = false + window.movingEnabled = true window.resize = windowResize window.maximize = GUI.windowMaximize window.minimize = GUI.windowMinimize + window.focus = GUI.windowFocus + window.eventHandler = windowEventHandler window.draw = windowDraw - window.movingEnabled = true return window end