PB 6.21 Beta 2 - DisableWindow not working correctly with QT Subsystem
PB 6.21 Beta 2 - DisableWindow not working correctly with QT Subsystem
DIsableWindow() works as expected using Gtk dialogs, but will disable both parent/child dialogs using the Qt subsystem (at least on the project I am working on).
Re: PB 6.21 Beta 2 - DisableWindow not working correctly with QT Subsystem
Please always post a small snippet showing the issue, thanks !
Re: PB 6.21 Beta 2 - DisableWindow not working correctly with QT Subsystem
Hello again,
Sorry for the delay, took some time to trim/narrow the code.
I could simplfy it further but wanted to maintain both dialogs logic well separated.
Sorry for the delay, took some time to trim/narrow the code.
I could simplfy it further but wanted to maintain both dialogs logic well separated.
- With Gtk subsystem, everything is as expected : child window opens as modal, with parent window disabled.
- With Qt subsystem, both child and parent windows are disabled (and as a side bug, child does not have a modal behavior : it does not stay on top).
Code: Select all
Global AppQuit.b = 0
Enumeration XML
#ParentWindowXML
#ChildWindowXML
EndEnumeration
Runtime Enumeration Dialogs
#ParentWindowDialog
#ChildWindowDialog
EndEnumeration
Debug "#ParentWindowDialog : " + Str(#ParentWindowDialog)
Runtime Enumeration DialogGadgets
#ParentWindowOpenChild
#ChildWindowOK
EndEnumeration
Declare.l OpenChildWindow()
Global ParentWindowXML.s = "<window id='#ParentWindowDialog' name='ParentWindow' text='' flags='#PB_Window_SystemMenu | #PB_Window_ScreenCentered'>" + Chr(10) +
" <button id='#ParentWindowOpenChild' text='Open modal child window'/>" + Chr(10) +
"</window>"
Global ChildWindowXML.s = "<window id='#ChildWindowDialog' name='ChildWindow' text='Child Window' flags='#PB_Window_WindowCentered | #PB_Window_SystemMenu'>" + Chr(10) +
" <button id='#ChildWindowOK' text='Close child window' flags='#PB_Button_Default'/>" + Chr(10) +
"</window>"
Procedure.l OpenParentWindow()
If ParseXML(#ParentWindowXML, ParentWindowXML) And XMLStatus(#ParentWindowXML) = #PB_XML_Success
If CreateDialog(#ParentWindowDialog) And OpenXMLDialog(#ParentWindowDialog, #ParentWindowXML, "ParentWindow")
ProcedureReturn 1
Else
Debug "XML Error : " + DialogError(#ParentWindowDialog)
ProcedureReturn 0
EndIf
Else
Debug "XML Error : " + XMLError(#ParentWindowXML) + " (Line: " + XMLErrorLine(#ParentWindowXML) + " | Position : " + XMLErrorPosition(#ParentWindowXML) + ")"
Debug ParentWindowXML
ProcedureReturn 0
EndIf
EndProcedure
Procedure ParentWindowGadgetEvent(Gadget.l)
Select Gadget
Case #ParentWindowOpenChild
OpenChildWindow()
EndSelect
EndProcedure
Procedure ParentWindowEvent(Event.l)
Select Event
Case #PB_Event_SizeWindow
If GetWindowState(#ParentWindowDialog) = #PB_Window_Normal
ParentWindowWidth = WindowWidth(#ParentWindowDialog)
ParentWindowHeight = WindowHeight(#ParentWindowDialog)
EndIf
Case #PB_Event_MoveWindow
If GetWindowState(#ParentWindowDialog) = #PB_Window_Normal
ParentWindowX = WindowX(#ParentWindowDialog)
ParentWindowY = WindowY(#ParentWindowDialog)
EndIf
Case #PB_Event_Gadget
ParentWindowGadgetEvent(EventGadget())
Case #PB_Event_CloseWindow
AppQuit = 1
EndSelect
EndProcedure
Procedure.l OpenChildWindow()
If ParseXML(#ChildWindowXML, ChildWindowXML) And XMLStatus(#ChildWindowXML) = #PB_XML_Success
If CreateDialog(#ChildWindowDialog) And OpenXMLDialog(#ChildWindowDialog, #ChildWindowXML, "ChildWindow", 10, 10, 50, 50, WindowID(DialogWindow(#ParentWindowDialog)))
DisableWindow(DialogWindow(#ParentWindowDialog), 1)
ProcedureReturn 1
Else
Debug "Erreur de la bibliothèque -Dialog- : " + DialogError(#ChildWindowDialog)
ProcedureReturn 0
EndIf
Else
Debug "XML Error : " + XMLError(#ChildWindowXML) + " (Line: " + XMLErrorLine(#ChildWindowXML) + " | Position : " + XMLErrorPosition(#ParentWindowDialog) + ")"
Debug ChildWindowXML
ProcedureReturn 0
EndIf
EndProcedure
Procedure CloseChildWindow()
DisableWindow(DialogWindow(#ParentWindowDialog), 0)
FreeDialog(#ChildWindowDialog)
EndProcedure
Procedure ChildWindowGadgetEvent(Gadget.l)
Select Gadget
Case #ChildWindowOK
CloseChildWindow()
EndSelect
EndProcedure
Procedure ChildWindowEvent(Event.l)
Select Event
Case #PB_Event_Gadget
ChildWindowGadgetEvent(EventGadget())
Case #PB_Event_CloseWindow
CloseChildWindow()
EndSelect
EndProcedure
Debug #ChildWindowXML
Debug #ParentWindowXML
If OpenParentWindow()
Repeat
Event.l = WaitWindowEvent()
Select EventWindow()
Case DialogWindow(#ParentWindowDialog)
ParentWindowEvent(Event)
Case DialogWindow(#ChildWindowDialog)
ChildWindowEvent(Event)
EndSelect
Until AppQuit = 1
EndIf
End
Re: PB 6.21 Beta 2 - DisableWindow not working correctly with QT Subsystem
This is the normal behaviour in Qt, unfortunately: https://www.purebasic.fr/english/viewtopic.php?t=71066.
I try to get it around it in my project by calling setWindowModality (I had to create a shared library/DLL to be able to do this). It would be good if we could do it through QtScript.
I try to get it around it in my project by calling setWindowModality (I had to create a shared library/DLL to be able to do this). It would be good if we could do it through QtScript.