Hello! I’m trying to do right click popup menus on buttons in maya so users know a button has a rigth click menu available.
Unfortunately when i set the custom cursor, I can’t seem to get it to allign with the original curser.
hotX, and hotY here seem to do nothing as far as I can see. When I move the cursor over the button it moves a little down and to the right no matter what values i provide here, whereas using the cmds.popupMenu on a button, the cursor image swap is seamless.
button.setCursor(QtGui.QCursor(':/rmbMenu.png', hotX=6, hotY=4))
full exmaple:
from PySide2 import QtCore, QtGui, QtWidgets
class MainWindow(QtWidgets.QDialog):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("MainWindow")
mainLayout = QtWidgets.QVBoxLayout()
self.setLayout(mainLayout)
self.btn = QtWidgets.QPushButton('Right Click Me!')
mainLayout.addWidget(self.btn)
self.btn.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.btn.customContextMenuRequested.connect(self.showPopup)
self.btn.setCursor(QtGui.QCursor(':/rmbMenu.png', hotX=6, hotY=4))
self.popupMenu = QtWidgets.QMenu()
self.PBSaveFileCB = self.popupMenu.addAction("Click")
def showPopup(self,position):
self.popupMenu.exec_(self.btn.mapToGlobal(position))
def showUI():
ui = MainWindow()
ui.show()
return ui
ui = showUI()