diff --git a/Applications/MineCode IDE.app/Main.lua b/Applications/MineCode IDE.app/Main.lua index d706a0f4..18982634 100755 --- a/Applications/MineCode IDE.app/Main.lua +++ b/Applications/MineCode IDE.app/Main.lua @@ -105,7 +105,7 @@ local overrideCodeViewDraw = codeView.draw codeView.draw = function(...) overrideCodeViewDraw(...) - if cursorBlinkState then + if cursorBlinkState and GUI.focusedObject == window then local x, y = codeView.codeAreaPosition + cursorPositionSymbol - codeView.fromSymbol + 1, codeView.y + cursorPositionLine - codeView.fromLine if x >= codeView.codeAreaPosition + 1 and diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 80d7152a..1385774c 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -4261,12 +4261,7 @@ local function windowEventHandler(workspace, window, e1, e2, e3, e4, ...) end if window ~= window.parent.children[#window.parent.children] then - window:moveToFront() - - if window.onFocus then - window.onFocus(workspace, window, e1, e2, e3, e4, ...) - end - + window:focus() workspace:draw() end elseif e1 == "drag" and window.lastTouchX and not windowCheck(window, e3, e4) then @@ -4337,11 +4332,22 @@ 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.focus = GUI.windowFocus window.resize = windowResize window.maximize = GUI.windowMaximize window.minimize = GUI.windowMinimize diff --git a/Libraries/System.lua b/Libraries/System.lua index 6b3e4a3d..cf824014 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -1663,7 +1663,7 @@ local function windowRemove(window) window.dockIcon.windowCount = window.dockIcon.windowCount - 1 -- Если в докиконке еще остались окна - if not next(window.dockIcon.windows) then + if window.dockIcon.windowCount < 1 then window.dockIcon.windows = nil window.dockIcon.windowCount = nil @@ -2251,12 +2251,16 @@ function system.updateDesktop() icon.onLeftClick = function(icon, ...) if icon.windows then - for window in pairs(icon.windows) do - GUI.focusedObject = window - window.hidden = false - window:moveToFront() + local topmostWindow + + -- Unhide all windows + for w in pairs(icon.windows) do + topmostWindow = w + topmostWindow.hidden = false end + topmostWindow:focus() + updateMenu() event.sleep(0.2) else @@ -2915,9 +2919,8 @@ _G.print = function(...) args = table.concat(args, " ") - system.consoleWindow.hidden = false system.consoleWindow.addLine(args) - system.consoleWindow:moveToFront() + system.consoleWindow:focus() end --------------------------------------------------------------------------------