Mouse behavior prevents tracking mouse events out of Iframe

0 favourites
  • 5 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Problem Description

    In a construct2 html5 exported project, where the project is hosted on my own website inside an Iframe which does not cover the entire screen.

    When I start to drag an object inside the construct 2 iframe and release the mouse outside the frame - the mouse up event is not fired.

    In your mouse plugin (runtime.js) - you have added a

    info.preventDefault() (line 116) in the mousedown event handler.

    This causes you to not track mouse events outside the construct 2 Iframe.

    Removing this line will cause the mouse event to track correctly even when leaving the Iframe.

    I have attached a jsfiddle that demonstrate the case:

    without the preventDefault in mousedown:

    http://jsfiddle.net/igalmirom/7z1y3L8v/

    with preventDefault():

    https://jsfiddle.net/igalmirom/ypm0cLxu/1/

    I guess that you prevented the mouse down for a reason but if you could workaround it in some

    other way it will help those who want to host a construct game on their own site and not in full screen mode.

    Attach a Capx

    http://1drv.ms/1c3pqYa - onedrive

    Description of Capx

    console.logs every mouse down and up event to demonstrate that they are not fired outside of the Iframe where the game is hosted

    Steps to Reproduce Bug

    • export capx in html5 format
    • embed the game in an Iframe on another webpage
    • start dragging the mouse inside the Iframe and release it outside the Iframe

    Observed Result

    In the first attempt both events (mouse down & up) will be logged to the console.

    In the second attempt and onward only the mouse down inside the Iframe will be fired

    Expected Result

    all mouse events are fired regardless of mouse pointer location.

    Affected Browsers

    • Chrome: Yes
    • FireFox: Yes
    • Internet Explorer: Yes

    Operating System and Service Pack

    windows 7

    Construct 2 Version ID

    release 200

  • I can't remember why it does preventDefault there. I've changed it for the next build anyway, I guess we'll find out why it was there if there was a reason

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Excellent! thank you.

    I could ditch the Iframe entirely if you would add a basePath param to cr_createRuntime.

    It's a change request but right now you get data.js and all media files with an XHR call relative to the current page path.

    This prevents loading construct on a page without an IFrame.

    If you could add a syntax such as:

     cr_createRuntime("c2canvas", { path: '/Content/Constuct2'});
    [/code:yj5xp1e7]
    
    Then I could host the game inside a page instead of an IFrame within the page.
    
    Thanks,
    
    Igal
  • I think there's too much on the parent page that could conflict with the C2 engine or its canvas tag, preventing it being able to easily integrate to existing pages. Embedding games with an iframe is the recommended way of integrating a C2 game in to an existing page.

  • fair enough

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)