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

TitleBar Buttons not working in some cases #1373

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Alessio2405
Copy link

@Alessio2405 Alessio2405 commented Mar 4, 2025

This fix addresses an issue that occurred when detecting whether the mouse was hovering over one of the TitleBar buttons (such as minimize, maximize, or close) of a window.
The previous method of detecting the mouse position could lead to incorrect results, particularly when the pointer was moved quickly from outside to inside the window.

Pull request type

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

When creating an instance of a window with a valid parent and displaying it using ShowDialog (I can reproduce this issue only with modal windows), there's sometimes a behavior where you are unable to click any of the titlebar buttons.
The only way to resolve this issue is by first giving focus to the content of the window and then returning focus to the titlebar area, making it difficult to interact with the titlebar buttons.

Issue Number: N/A

What is the new behavior?

  • Fixed MouseOver detection: The logic for detecting mouse hover over the TitleBar buttons has been improved. The method now consistently detects the mouse position by using an interop function to ensure the accuracy of this calculation.
  • Correct transformation of coordinates: The transformation from screen coordinates to local window coordinates is now checked, even when device scaling or window transformations are in place, ensuring accurate hit testing on the TitleBar buttons.

Other information

N/A

@Alessio2405 Alessio2405 requested a review from pomianowski as a code owner March 4, 2025 16:15
@github-actions github-actions bot added controls Changes to the appearance or logic of custom controls. PR Pull request dotnet release titlebar Titlebar updates labels Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls Changes to the appearance or logic of custom controls. dotnet PR Pull request release titlebar Titlebar updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant