Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: ParentNotify not working for sub-window  (Read 7574 times)

0 Members and 1 Guest are viewing this topic.

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
ParentNotify not working for sub-window
« 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.
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: ParentNotify not working for sub-window
« Reply #1 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.     }
     
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: ParentNotify not working for sub-window
« Reply #2 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?
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: ParentNotify not working for sub-window
« Reply #3 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 :)
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: ParentNotify not working for sub-window
« Reply #4 on: January 22, 2014, 02:29:44 PM »

Parent of the button is window, not a parent window.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: ParentNotify not working for sub-window
« Reply #5 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?
Logged

MrBehemoth

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • View Profile
Re: ParentNotify not working for sub-window
« Reply #6 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.
 

Page created in 0.028 seconds with 25 queries.