[Closed] Shortcut issues when custom GUI is opened
I encountered the following problem:
I have written a macroscript which generates a GUI written in PySide (python). This opens in a seperate window and is thus not docked in the UI of 3ds max. However each time I go back to the window of the UI of 3ds max and want to use a keyboard shortcut, nothing happens. If I close my custom GUI, the keyboard shortcuts respond again. I tried googling but failed to find a solution for this problem.
Can somebody help? Thank you
Edit: the GUI is completely created in python, in the macroscript there is the following code:
macroScript GUI
category:"DragAndDrop"
toolTip:""
(
python.ExecuteFile "C:\\Test \\GUIQT.py"
)
When I open other GUI’s which are fully made in macroscript, keyboard shortcuts respond.
it’s because your pyside UI holds keyboard focus. the dialog you made is not truly max child window.
is this exposed to pyside ?
virtual void Interface::RegisterDlgWnd ( HWND [i]hDlg[/i] ) [pure virtual]
Remarks: Registers a dialog window so IsDialogMessage() gets called for it. This is not required if you add rollup pages to the command panel as this is done automatically, however if you create a floating, modeless dialog you must call this method.
Important Note: ALL modeless dialogs in MAX must be registered to the application window with this method so that it, and any sub dialogs, will behave as they should. Parameters: HWND hDlg
The window handle of the dialog.
First of all, thank you both for the replies. They were both very helpful.
To answer Klvnk’s question, I found a method which I believe has the same functionality as the method he mentions but then in python. I believe that if it is exposed in python, that it is also exposed to pyside?
def RegisterDialogWindow(HWND hDlg)
I think it is the method that I need, however do you have an idea what the arguments are? There isn’t a HWND class in Python API of 3ds max to create one. I have the following methods in the same class (Win32 ) as the RegisterDialogWindow(args) function:
def GetMaxHWnd() -> HWND
def GetStatusPanelHWnd() -> HWND
def GetViewPortHWnd() -> HWND
but I do not know which one I should use? I would say the first but I’m not fully sure. I also found the following method in the same class:
def Set3dsMaxAsParentWindow(HWND h) -> bool
Could this also be useful? There isn’t any explanation with the functions in the Python API so if anyone could help me understand what these functions exactly do, I would be very grateful.
I fixed my problem! I found out that other python pyside UI don’t keep the focus of the keyboard and that there must be something that I was doing wrong. Basically there was one line of code that shoudn’t have been there, more specifically the app.exec_():
app = QtGui.QApplication.instance()
if app == None:
app = QtGui.QApplication([''])
ui = mApp()
ui.show()
#app.exec_()
Without this last line of code, everything works! Still big thanks to Klvnk and denisT for their help!