Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: pakhpakh64 on March 06, 2013, 03:07:00 PM

Title: nested window - how to get control?
Post by: pakhpakh64 on March 06, 2013, 03:07:00 PM
hi every body
I have a ParentWindow and a ChildWindow witch is nested inside ParentWindow, inside ChildWindow I have butten like "open".
the question is how can I handle clicking on "open" button INSIDE ParentWindow's script?
I hope I've made myself clear!  :P
thanks in advance.
Title: Re: nested window - how to get control?
Post by: 2.0 on March 06, 2013, 06:53:52 PM
For example, you need to attach the script file to the ChildWindow.
In there try to use something like that:

Code: WME Script
  1. on "open"
  2. {
  3.   var ParentWindow = this.Parent
  4.   ParentWindow.ApplyEvent("open");
  5. }

and catch the "open" event in the parent's script.

hi every body
I have a ParentWindow and a ChildWindow witch is nested inside ParentWindow, inside ChildWindow I have butten like "open".
the question is how can I handle clicking on "open" button INSIDE ParentWindow's script?
I hope I've made myself clear!  :P
thanks in advance.
Title: Re: nested window - how to get control?
Post by: pakhpakh64 on March 07, 2013, 02:20:25 PM
thanks, I will try this.
Title: Re: nested window - how to get control?
Post by: pakhpakh64 on March 12, 2013, 03:35:46 PM
This didn't worked for me neither. I used the method in one template project of WME for handling menu windows (suck as main menu and save/reload window), and it worked fine.
Title: Re: nested window - how to get control?
Post by: Jose on March 12, 2013, 05:41:41 PM
The method posted by 2.0 works fine.

First of all you need to set to 'True' the ParentNotify attribute of the 'open' button (let's assume the name of the button is 'open') control in your Child Window. Then in the script attached to your Child Window you have to define the following event handler:
Code: [Select]
on "open"
{
  var parentWindow = this.Parent;
  parentWindow.ApplyEvent("open");
}

Finally, in the script attached to your Parent Window you have to define the event handler for the 'open' event:
Code: [Select]
on "open"
{
   // Handle the event...
}
Title: Re: nested window - how to get control?
Post by: pakhpakh64 on April 09, 2013, 02:03:45 PM
sry for the late reply, I did it and it works fine, Thanks.