04-02-2015 09:03 AM
Hi, all
I did some refactoring of the example, and the problem seems to be solved by making the child and grandchild panels children of their parent panels. There is a note in InstallPopup
which warns that 'unexpected behavior' might result from using child panels as modal dialogs, and this appears to be because InstallPopup
temporarily promotes child panels to the level of parent panels until RemovePopup
is called. During that interval in which the child popup is no longer a child, if you try to use child-panel specific features for the popup, unexpected things can happen.
Please see the attached project.
Thanks,
04-02-2015 09:29 AM
That is EXCELLENT!!!!!!!! thank you 🙂
Is this documented anywhere? or was it found by accident?
Either way I appreciate your concern and the fix.
04-03-2015 07:47 AM
I must admit that I don't understand the problem: can somebody explain me?
Let's look at the original project supplied by PopUpProblem:
When I press "Create a child" the popup is created and no action can be taken in the original panel: ok, that's what popup panels are for.
When I press "Create a grandchild" the panel is created and no action can be taken on the first two panels. That should be good again.
When I dismiss the grandchild I can still operate on the child and when I dismiss this last one I can operate on the parent panel.
The modification by dcubed works the same way.
What am I missing??
04-03-2015 08:03 AM
Hi Roberto,
The problem, as I understand it, is that the GetUserEvent
does not react to EVENT_COMMIT
events from clicking the grandchild window's 'Done' button until EVENT_COMMIT
events are raised by the child window's 'Done' button. You can see the difference in behavior by changing the following code from:
if ((_fatherPanel = LoadPanel( 0, "FatherUir.uir", PANEL )) < 0) return -1; if ((_childPanel = LoadPanel( _fatherPanel, "ChildUir.uir", CHILD )) < 0) return -1; if ((_grandchildPanel = LoadPanel( _childPanel, "ChildUir.uir", GRANDCHILD )) < 0) return -1;
to
if ((_fatherPanel = LoadPanel( 0, "FatherUir.uir", PANEL )) < 0) return -1; if ((_childPanel = LoadPanel( 0, "ChildUir.uir", CHILD )) < 0) return -1; if ((_grandchildPanel = LoadPanel( 0, "ChildUir.uir", GRANDCHILD )) < 0) return -1;
in my attached code.
04-03-2015 08:38 AM
Ok, I didn't focused on the buttons having a callback themselves.
I see what you are saying, but I consider using control callbacks AND GetUserEvents together a risky way and frankly it seems a bad programming habit to me.
I cannot even figure a reason to handle the very same commit event two times in different moments in program life.
When I use popup+GetUserEvents I set no callbacks on buttons and handle all commit events inside a loop on GetUserEvents; alternatively, I set controls as 'normal' and trap click or value change or other events inside the control callback. This way I am guaranteed that events are processed by one manager only. I do not want to run the risk that under unpredicted conditions events are handled in a different order by concurrent managers.
04-06-2015 07:05 AM
I have 2 questions for D_Cubed regarding your example code.
1- What is the meaning of the underscore preceding all the user defined variables?
2- Why the RemovePopup instead of the HidePanel? By doing a HidePanel I believe I can repaint it without reloading it, where as by Removing it I believe I have to do a re-load.
04-07-2015 04:02 PM
Hi PopUpProblem,
g_
or some other prefix, but I prefer a simple _
. You'll notice that it is not all user-defined variables that follow this convention; locally-scoped variables in the example do not have a prefix (e.g., whichPanel
).RemovePopup
, because it is the correct function to use when removing pop-up panels. For more information on using LabWindows/CVI pop-up panels, see programming with pop-up panels in the help. You do not need to re-load a panel after calling RemovePopup
.
I hope that helps!
04-08-2015 06:54 AM
Thanks for the clarifications 🙂