Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing a Window via the close button does not unset the hot region #33

Closed
sdleffler opened this issue Jun 27, 2020 · 3 comments
Closed

Comments

@sdleffler
Copy link
Contributor

When closing a window via the close button, if BeginWindow is not later called with IsOpen = false (going from BeginWindow(... { ... IsOpen = true ... }) to not calling BeginWindow at all but still calling Slab.Update) then the Region.HotInstance variable remains set to the now closed window and does not get corrected until another Slab object is hovered over and then unhovered. This interferes badly with Slab.IsVoidHovered.

@sdleffler
Copy link
Contributor Author

Proposed fix: provide a Region.Obstruct() function which checks to see if the active region is the hot region, and if so, nils the hot region. This can be called from the same block in Window.lua which checks to see if the close button is clicked:

			if IsCloseHovered then
				DrawCommands.Circle(
					'fill',
					CloseX,
					CloseY,
					CloseBgRadius,
					Style.WindowCloseBgColor
				)

				if Mouse.IsClicked(1) then
					ActiveInstance.IsOpen = false
					Options.IsOpen = false
					ActiveInstance.IsMoving = false
					
					Region.Obstruct()
				end
			end```

@sdleffler
Copy link
Contributor Author

sdleffler commented Jun 27, 2020

I think I've found a better solution - this seems to be solved more neatly and robustly by adding a frame number counter to Region in a similar manner to Window, and then in Region.GetHotInstance we can check whether or not the hot instance has been updated within the last couple frames; if not, nil it out and return the empty string. This makes Region.Obstruct() unnecessary and should solve the ghost-hot-region issue at its source. Makes me wonder whether Window's frame number counter should be moved to Region instead?

@coding-jackalope
Copy link
Collaborator

Hi @sdleffler thanks for reporting this issue. I was able to reproduce this and have checked in a fix. You can see the commit at 5395f26. This fix will be added to the next update.

I went with keeping the frame number in Window since it is used to update what windows are visible and their stack order. I added a function to clear the hot region if the given window has been removed from the stack. This is handled in Window.Validate which is called every Draw before the actual rendering occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants