Suggestion: Mousewheel - remove preventDefault()

For developers using the Construct 2 Javascript SDK

Post » Wed Oct 02, 2013 12:55 am

In my game, I let the user zoom in and out on the map by using the mousewheel, which is pretty standard nowadays. I also have some HTML-based list boxes on my HUD using the List object. Normally, the user can scroll in these list boxes using the mousewheel when mouse hovers over it, which is a great usability feature. However, when I enable mousewheel zooming on the map, the scrolling in the list box no longer works.

The problem is that the official Mouse plugin on line 174 runs preventDefault() when it captures a mousewheel event, which overrides any default events, such as scrolling of list boxes.

If I manually edit the plugin and remove this line, it works just as expected, so my feature request is that you either disable preventDefault(), or better yet make it into a setting in the Mouse object. Although I'm not entirely sure of when it could be useful (IE compatibility?), making it into an option would reduce the risk of compatibility issues, if you leave it enabled by default.

Thanks for listening!SirSpunky2013-10-02 00:57:36
B
18
S
3
Posts: 57
Reputation: 1,081

Post » Wed Oct 02, 2013 6:08 am

Does it work to disable it while the mouse is hovering over the list object?Paradox2013-10-02 06:09:28
B
242
S
63
G
33
Posts: 903
Reputation: 40,756

Post » Wed Oct 02, 2013 11:36 am

@Paradox
No, unfortunately not, it still seems to run preventDefault, even if I condition it on mouse not hovering the list object. That would be another way to solve it I guess, to only make it preventDefault when the event is actually run.
B
18
S
3
Posts: 57
Reputation: 1,081

Post » Wed Oct 02, 2013 1:16 pm

If we simply remove it, some games will start scrolling the page around when you use the mouse wheel, which will make them unplayable. Perhaps post a bug report with a minimal .capx repro and I'll see if I can tweak it until it works.
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Wed Oct 02, 2013 6:38 pm

@Ashley
Ah, of course. I sometimes forget that Construct 2 is also used to make embedded web games, as I'm working on a full stand-alone game.

Here's a bug report with a .capx:
http://www.scirra.com/forum/topic76648_post458873.html
B
18
S
3
Posts: 57
Reputation: 1,081


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests