Mouse behavior prevents tracking mouse events out of Iframe

Bugs will be moved here once resolved.

Post » Fri May 01, 2015 6:56 pm

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
B
4
Posts: 3
Reputation: 206

Post » Thu May 14, 2015 1:32 pm

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 :P
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Thu May 14, 2015 1:44 pm

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:
Code: Select all
 cr_createRuntime("c2canvas", { path: '/Content/Constuct2'});


Then I could host the game inside a page instead of an IFrame within the page.

Thanks,

Igal
B
4
Posts: 3
Reputation: 206

Post » Thu May 14, 2015 1:54 pm

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Thu May 14, 2015 2:21 pm

fair enough :mrgreen:
B
4
Posts: 3
Reputation: 206


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests