Disable mouse wheel scroll for web player page

Our game uses mouse wheel to control zooming in and out in the web player.

We have an issue with browsers still responding to the scroll event, even when the web player has focus - it catches all the keyboard events, but mouse events get through, so if the player just wants to zoom in, the whole page scrolls.

Is there a way of disabling scrolling of a web page with the mouse wheel? I still want the user to be able to scroll by dragging the scrollbars or even using the wheel, but this one only if web player doesn’t have focus.

If that can’t be fixed, there’s no much point in using the mouse wheel in web player for anything, is there?

Thanks for your help :smile:

We have the same problem. It’s likely a bug in the 2.5 Webplayer as we’ve never encountered this problem on 2.1.
We’re searching for workarounds now, but so far, haven’t found a good solution.

Best regards
Shaun

Hmm… Sounds like a bug in the webplayer, although I have no experience with it. (Partly because I never scroll. Curse you faulty Apple scrollball!)

A workaround would be needed to stop the page from scrolling if the webplayer won’t do it. Easier said than done, however I’ve concocted a concept that should serve as an adequate hack:

Application.ExternalEval('document.body.style.position="fixed";');

When the above is run in a webplayer, the page it’s in should lock to the top and not budge an inch. That’s the concept anyway; I’m worried that something bad will happen, like the webplayer-scroll-flicker showing up for no reason, but javascript command itself seems to work fine with OmniWeb and Safari 4.

Hope it helps.

By the way, it goes without saying to make sure that the player is visible. If needed, the page can be moved by setting negative “top” or “left” values in it’s style. ie:

document.body.style.top= -100px;

will scroll the page up 100 pixels when it’s position is “fixed”.

Yep. Our web dev was playing around with this too, and it seems to work. We’ll call this when we enable mouse lock, and disable on release. Final thing is to make it work on all browsers (Windows IE was currently doesn’t work) - last 10% is always 90% of the effort :slight_smile:

Best regards
Shaun

Why am I not surprised? :lol:

Bad news, seems that Unity resets on style change. Back to square one, unless anyone else has an idea.

Best regards
Shaun

Interesting. It works fine in Safari (Webkit), but not Camino (Gecko). Stupid web browsers…
Ah, well… as I said, it’s a hack. File a bug report.

(sigh)

Oh, how I love the wealth of browser variations :wink:

Unity resets on style change? Wow, I have to see it to believe it…

The idea with locking the page with position:fixed looks good, especially if you use only when mouse cursor is over the player. Too bad it doesn’t work, but I’ll try to follow that track.

I have a feeling though, that there is a general notion among web developers, that preventing the user from scrolling, when he clearly sees that there’s something to scroll down to, is bad usability design and may you be cursed forever, and so on.

So maybe it’s not a coincidence that there’s no good way of doing this - browser developers might think you shouldn’t be asking for it in the first place :wink:

The solution we used for puzzlebloom.com was to resize the player to the inner browser window size. I don’t like the solution that much, but it’s the only (semi-)reliable we have for now.

http://forum.unity3d.com/viewtopic.php?p=247286#247286

I originally wanted to be a website designer, not a programmer. Then I tried my website on more than one browser and resolution realized it was too much of a pain. Started programming realized how fun the logic is and how much better it is. Then I saw the average pay… Go to hell web design.

Thanks Russian Madman