Fire Changed Event for GUIs on Window Maximize/Unmaximize

I have a script that scales my GUIs based on the changing of the ScreenGuis AbsolutePosition/Size
I could use a while loop to avoid it screwing up the GUIs when it doesn’t fire, but this would be more efficient, it should fire anyway as the values do change.

You can use the WindowFocused and WindowFocusReleased events of UserInputService for this, I believe

Does it fire on maximize/unmaximize? I was under the impression it was for only when you switched active windows/minimizing.

ScreenGuis AbsoluteSize should work for anything that changes the window’s size. If the window is minimized, filiptibell’s idea should work fine, and at least tell you the window is out-of-focus, although that doesn’t always mean minimized.

1 Like

Here’s my issue when using ScreenGui.Changed to know when to reposition a GUI. (Notice that maximize/unmaximize messes it up until I actually change the screen size manually.)
https://dl.dropboxusercontent.com/u/53742709/ShareX/2016/05/2016-05-16_15-47-25.mp4
Thats the gist of my underlying code. (RecalculatePositions functions recalculates my stored UDim2 positions that are in a table since many elements scale relative to the position and size of other elements)

GUI.Changed:connect(function()
	RecalculatePositions()
	if Flags.MainMenuWindow then
		RepositionElements("MainMenuWindow")
	elseif Flags.CreditsWindow then
		RepositionElements("CreditsWindow")
	end
end)

What OS are you using? If I print out the absolute size of the screengui on the changed event, it appears to be coming out ok.

Windows 10. I don’t even need the ScreenGui’s absolute size value I believe, its as far as the Changed event firing which triggers the rescale. So my initial thought is that its firing before it finishes the maximize/unmaximize process.

Still having this issue. Upon maximize/unmaximize, WindowFocused and WindowFocusReleased does not fire.
GUI.Changed still gives me bad results. (It does report the right AbsoluteSize results, but its as if my function completely ignores that.)
I have no idea whats going on here.

It fires 2 functions every time it changes, and even sometimes after it changes by 1 pixel, it corrects some elements, then doesn’t correct the rest until the next change. (There’s also inaccuracies when I change the screen size drastically)

Edit: Adding a wait() fixes the inaccuracies, but Maximize/Unmaximize is still messed up

https://dl.dropboxusercontent.com/u/53742709/ShareX/2016/05/2016-05-21_12-51-05.mp4