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

Gui: Optimize TreeWidget Context Menu Behavior with Sync View: Suppress Selection Change on Right-Click #15419

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

farleyrunkel
Copy link
Contributor

@farleyrunkel farleyrunkel commented Jul 14, 2024

This Pull Request addresses issue #15418 by fixing the incorrect context menu display when right-clicking on items in the TreeWidget, especially when the Sync View command is enabled.

The main reason for this issue is that right-clicking an item in Qt's QTreeWidget triggers the onItemSelectionChanged event, which activates the document item. As discussed in issue #13643, we shouldn't activate a document when right-clicking.

To fix this, the selection change on right-click is suppressed. This ensures that the correct context menu appears, improving the user experience and keeping the functionality consistent.

@github-actions github-actions bot added the Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Jul 14, 2024
@farleyrunkel farleyrunkel changed the title Suppress selection change when right-clicking on an item in TreeWidget for solving the problem #15418 Optimize TreeWidget Context Menu Behavior with Sync View: Suppress Selection Change on Right-Click Jul 14, 2024
@maxwxyz maxwxyz added this to the 1.0 milestone Jul 14, 2024
@farleyrunkel farleyrunkel changed the title Optimize TreeWidget Context Menu Behavior with Sync View: Suppress Selection Change on Right-Click Gui: Optimize TreeWidget Context Menu Behavior with Sync View: Suppress Selection Change on Right-Click Jul 14, 2024
@chennes
Copy link
Member

chennes commented Jul 15, 2024

Thanks for the PR! This adds a new state to the code, so needs some further testing. In particular, the state is only set inside the mouse handling code, but selection can be changed in other ways (programatically, for example). Also, the ternary operator isn't necessary, since the result is a boolean.

@chennes chennes marked this pull request as draft July 22, 2024 15:38
@chennes
Copy link
Member

chennes commented Jul 22, 2024

I'm switching this to draft pending updates to the code to ensure that state is correctly set and reset under other code paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gui: changing documents on right click in the tree view still displaying the wrong context menu
3 participants