Javascript code, UI elements and Mouse Clicks


#1

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…


#2

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.


#3

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

https://worklist.net/20302

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


#4

@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 ( https://worklist.net/20303 )? If not, I will take it back out of default scripts and we can come up with something.


#5

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


#6

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


#7

@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 ?


#8

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

https://dl.dropboxusercontent.com/u/121169/lookWithMouse-Fixed.js


#9

@coal and @ctrlaltdavid great stuff. @coal check out the PR https://github.com/highfidelity/hifi/pull/4233 . Let me know what you think?


#10

@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;
}

to;

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:


#11

@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.


#12

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.


#13

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.


#14

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