Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: anarchist on January 12, 2014, 05:55:14 PM

Title: ParentNotify not working for sub-window
Post by: anarchist on January 12, 2014, 05:55:14 PM
Hello all,

Not certain whether this is expected behaviour or if I am doing something wrong. I have a window which contains a nested window. The nested window contains a button named "btnOption1". Both the button and the nested window have ParentNotify = true.

Indide the parent window's script I have added:

Code: WME Script
  1. on "btnOption1"
  2. {
  3.         //do something
  4. }
  5.  

I am expecting this to be called when I press the button inside the nested window. Unfortunately, this is not the case. I set a breakpoint here (I have some code, not comments) and it is never reached.

I have moved the button inside the parent window and the above code is reached. Therefore, something is wrong with the nested window. Do I need to add a script to catch the button press event?

I am working with WME Project Manager 1.10.001 which is still in beta, so I am not sure if this is a bug.
Title: Re: ParentNotify not working for sub-window
Post by: 2.0 on January 13, 2014, 12:01:15 PM
Yes, in the main window script you need to define some method, for example:
   
Code: WME Script
  1.     on "NestedButton"
  2.     {
  3.             //do something
  4.     }
     
And in the nested window script:

Code: WME Script
  1.     on "btnOption1"
  2.     {
  3.             var Window = this.Parent;
  4.             Window.ApplyEvent("NestedButton");
  5.     }
     
Title: Re: ParentNotify not working for sub-window
Post by: anarchist on January 13, 2014, 06:22:41 PM
Thanks 2.0, that is exactly the information I needed.

A more general question that rises from this is: Since the nested window does not send the events to the parent, what is the use of ParentNotify?
Title: Re: ParentNotify not working for sub-window
Post by: 2.0 on January 14, 2014, 03:13:06 AM
It works for buttons within the window at least. As about windows - well, every day is not Sunday :)
Title: Re: ParentNotify not working for sub-window
Post by: metamorphium on January 22, 2014, 02:29:44 PM
Parent of the button is window, not a parent window.
Title: Re: ParentNotify not working for sub-window
Post by: anarchist on January 24, 2014, 12:07:17 AM
Parent of the button is window, not a parent window.

I understand that, but shouldn't the parent window be notified with event "btnOption1" when button triggers that event in the sub-window (provided that the sub-window does not handle the particular event in its script)?

btnOption1 clicked -> nested window event btnOption1 triggers -> nested window does not handle event -> parent window event btnOption1 triggers

Is the above logic flawed?
Title: Re: ParentNotify not working for sub-window
Post by: MrBehemoth on January 25, 2014, 11:22:39 AM
What you're saying makes sense, but ParentNotify only seems to work for buttons as far as I can tell, so you can't chain it like that. 2.0's answer is the best way to go.