paperElectron

Stopping event propagation in GUI overlay.

Recommended Posts

Hey all, I'm currently building a UI layer for a multiplayer game I am working on, and cant seem to stop events from propagating to the canvas layer.

 

My Html structure (In jade), places all of the elements inside a relatively positioned container, with all of the child elements absolutely positioned and z-indexed above the #game container. All of the gui layers are display: none, and I have several methods available to call out of the game to display them. All of this works well and good, but any events I attach to these DOM objects propagate down to the canvas, even with stopPropagation() and stopImmediatePropagation() called on the event.

 

.gameContainer    .gui#resources      .guiInner.white        h1 Main    .gui#console      .guiInner        ul#chatList.list-unstyled      .chatInput        input#consoleInput(type="text")    .gui#settings      h1 Settings    .alert#alert    #game
My in game GUI buttons are simply Phaser buttons that call out of the game to my GUI class. My event handlers are standard jQuery event handlers.

//Phaser GUI buttontoggleGui = this.game.add.button(900, 600, "button", GameObjects.Gui.showResourceGui, this, 0, 1, 2);//Event handler outside Phaserchild.mouseup(function(e) {  this.hide("fade", function() {    return this.remove();  });  return e.stopPropagation();});
Any Ideas? I pretty much want to stop all Phaser events while the GUI overlay is up.

Share this post


Link to post
Share on other sites

The buttons in this overlay will still work because it is an HTML overlay. 

Of course, if you have a custom display object in Phaser as an overlay, you can't disable all the input; but as your buttons will catch the phaser events, it won't reach another object behind the overlay.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.