Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Close event on "Menu" window  (Read 3590 times)

0 Members and 1 Guest are viewing this topic.

fsaenz

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 20
    • View Profile
Close event on "Menu" window
« on: January 12, 2012, 11:38:13 PM »

Hello!

    Please Excuse my English but it's not my native language.
    I'm working on a Game that needs to animate the closure of the action menu (Take-Lookat-Talk).

    The thing is, that I can't find a way to execute code when the engine closes the window. The window is a "Menu" window, that automatically closes the window when the user clicks outside it.
     
     My idea is to use "SetImage" on the window to set an Animated Sprite.

Thanks in advance!  :)
Francisco.-
   
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Close event on "Menu" window
« Reply #1 on: January 13, 2012, 10:07:24 PM »

Welcome fsaenz!
You can set an animated sprite when the close event occur...before calling the window.Close() method, but you have to manage other elements in the window (like title, text, buttons...)

I think that you have to write a function wich sets all other elements' visible attribute to false and then sets the animated sprite
Logged

fsaenz

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 20
    • View Profile
Re: Close event on "Menu" window
« Reply #2 on: January 13, 2012, 10:24:46 PM »

Hello Ennio!

    Thanks for your reply! but setting the animated sprite it's not my problem.
    My problem is that I don't call the close() method, It is called by the engine (is a "Menu" window) and I can´t find a way to execute code when the engine closes the window.

Thanks anyway!
Francisco.-
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Close event on "Menu" window
« Reply #3 on: January 14, 2012, 12:39:00 AM »

It's not controlled directly by the engine, maybe the code you need to modify is in your game.script file (scripts/game.script)
There you can see a function "on Right Click" that controls menu window behaviour, there you can modify code as you wish!

There are two lines like
// is the righ-click menu visible? hide it
  if(WinMenu.Visible == true) WinMenu.Visible = false;

so this is the part of code where you can add instructions to "close" (or just make invisible, like the code above), even using animation

I've never try to code something like this yet, but i think this can be a solution !
Logged

fsaenz

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 20
    • View Profile
Re: Close event on "Menu" window
« Reply #4 on: January 14, 2012, 01:33:33 AM »

Hello Ennio!

    Thanks Again!
    I noticed the "Right click" code, but that's not where my problem arise.  :(
   
    If you see in the same Game.Script, there is no "WinMenu,Visible = false" in the "Left Click" event. Yet, if you click outside the menu the window closes. (that's because of the "Menu" style enabled from the Editor)

    In that particular moment, the "Left Click" event in the Game.Script it's not executed...
    I tried to put a "Left Click" event on the Menu.script, but that code it's no executed...
    I asume that the window is closed by the engine somewhere, And I don't know how can I intercept that event.  :-[

Thanks anyway!
Francisco.-
   
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Close event on "Menu" window
« Reply #5 on: January 15, 2012, 02:21:18 PM »

You can't intercept closing of the menu windows.

What you'd need to do is not to use the .Menu property, but reproduce the behaviour yourself. Behind the scenes WME creates a huge invisible button behind the window, so when you click outside the menu window, you actually press the invisible button, which closes the window.

To reproduce this yourself, your menu window would contain:

a) a full screen transparent window
b) a button covering the window
c) a second nested window - the actual action menu

The invisible window would stay at the same position, you'd only reposition the nested window to place the action menu. When the user clicks outside the action menu, he will press your invisible button, and then you can intercept the event and do whatever you need to do. Makes sense?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fsaenz

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 20
    • View Profile
Re: Close event on "Menu" window
« Reply #6 on: January 15, 2012, 03:43:29 PM »

Hello Mnemonic!

    Thanks for your reply, and of course it make sense!
 
    I thought about a full screen window, as I use that same idea with the inventory. But as the Action menu moves from place to place and I find it very difficult to achieve.   
    Your idea of nested windows is very convenient, and surely it will suit my purposes. It's my first time using them, but I hope that I'll be able to learn how from other forum posts.  ;D

Thanks again for the response.
Francisco.-

Logged
 

Page created in 0.036 seconds with 19 queries.