Javascript code, UI elements and Mouse Clicks


One huge deficiency being seen with the otherwise excellent concept of Interface being so easily customized/extend via JavaScript code blocks is in how mouse clicks are handled.

Is there a way to have the clicks bubble down (or up) such that, for instance, when lookWithMouse.js is enabled it does not destroy ability to toggle audio or stats display (% key onscreen stats)? This seems something that really needs to happen, otherwise one script takes over everything…


lookWithMouse.js / Interface interaction needs be fixed now that lookWithMouse.js is included in defaultScripts.js - you currently can’t toggle your microphone unless you stop lookWithMouse.js from running.


And I added a worklist item for this as well at;

Please comment if 1) I didn’t explain it correctly or 2) this matters to you.


@ctrlaltdavid and @OmegaHeron yep… I added it into default script then remembered that issue. It is only on UI elements that are generated outside of .js.

Can either of you guys think of a quick solution ( )? If not, I will take it back out of default scripts and we can come up with something.


I don’t have enough knowledge, but, off the cuff guess would be to have JS engine pass on clicks to main UI vs only intercepting. We can withdraw my worklist 20302 since it duplicated your 20303, only difference is mine is more in a general sense of all scripts while yours is in reference to a specific, but - fixing one fixes both if the UI ends up still receiving click events. @Chris


Comparing lookWithMouse.js and inspect.js which does similar things …

lookWithMouse.js does Controller.captureMouseEvents() which must disable Interface and other scripts from getting mouse events.

inspect.js doesn’t do Controller.captuerMouseEvents(), but it still processes mouse events but only takes action if the Alt key and left mouse button are held down.

Just removing the lines Controller.captureMouseEvents() and Controller.releaseMouseEvents() in lookWithMouse.js seems to let things work OK.



@chris, You still need to press a mouse button before you can look around… Is replace the left mouse button for the right mouse button in lookwithmouse.js not a workable option ?


I edited the script to only accept the right mouse button (and applied the other fixes) but you can edit it and find the RIGHT and change it to LEFT


@coal and @ctrlaltdavid great stuff. @coal check out the PR . Let me know what you think?


@Chris - this, I would think, would be optional, but if one didn’t want to constantly do reset sensors for returning to “even” moving stance… change;

function mouseReleaseEvent(event) {
isMouseDown = false;


function mouseReleaseEvent(event) {
MyAvatar.headPitch = 0;
isMouseDown = false;

This will reset your view to forward, but it won’t allow you to pan, release mouse and stay at that view angle. I’m torn as to which is better, but, I’m wearing out ’ key with all my sensor resets, so… :slight_smile:


@OmegaHeron I am torn as well. I do like to look in a direction and hold the position. Yet, there is nothing stopping someone just having there own version that they like.


Yeah, I don’t think that modification should be in default code, but it’s an easy add. If one wanted to get really fancy you could do middle mouse - moves to look at angle and keeps, left moves then snaps back and right brings me another cup of coffee.


I like the PR, I just added it so it used the right mouse button to move but here is how I feel @OmegaHeron and @chris, why not set a variable at the top others can change? That’s what I am going to do with my code to allow them to edit the script on their local drive and change it if they want like bindKey = LEFT; BUT you can set a global at the top for resetLook = false; and the user choose later in the JavaScript. Just my thought on it.


For right now, the simple fix PR has been merged and script updated on S3.