Wolfmyths / Myth-Mod-Manager

An easy way to swap and manage Payday 2 mods outside the game
https://modworkshop.net/mod/43276
MIT License
9 stars 4 forks source link

[PySide6] How to make QAction ignore right clicks with QEventFilter #26

Closed Wolfmyths closed 7 months ago

Wolfmyths commented 1 year ago

For an Example:

import PySide6.Widgets as qtw
import PySide6.QtGui as qtg

class ModContextMenu(qtw.QMenu):
    def __init__(self, parent) -> None:
        super().__init__()

        action = qtg.QAction('Enable', self)

        self.addAction(action)

How can I set this up to trigger QEventFilter so if the mouse button pressed isn't left click, cancel the event from firing?

I tried setting up the QEventFilter from within this class and it never was fired.

There is a fix in place for this issue but I want to refactor it because there would be a lot less code using the QEventFilter

Wolfmyths commented 7 months ago

Found a workaround