I’ve been working on another task in the MouseLock implementation: When ESC key is pressed, mouse lock should exit.
I’ve been going through mxr, dxr and comments in other mozilla bugs, and came up with the following code that we might need to check for the ESC key press:
nsEvent* aEvent; const nsKeyEvent* keyEvent = static_cast<const nsKeyEvent*>(aEvent); int key = keyEvent->keyCode ? keyEvent->keyCode : keyEvent->charCode; if (key == NS_VK_ESCAPE) { fprintf(stderr, "Escape key is pressed!"); mIsLocked = PR_FALSE; }
However, it doesn’t work for now.
It builds if I insert it in the lock method for now, but I am not sure how to make it work. How will the lock/unlock method know to listen for this event? I am not sure how to implement that in c++ yet…will continue working on that.
Also, to those who need help setting up Visual Studio as their FF debugger on Windows: and https://developer.mozilla.org/en/Debugging_Mozilla_on_Windows_FAQ
—————————
Update:
Just found this piece of code:
// if we can use the keyboard (eg Ctrl+L or Ctrl+E) to open the toolbars, we // should provide a way to collapse them too. if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) { FullScreen._shouldAnimate = false; FullScreen.mouseoverToggle(false, true); }
http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#4027
Maybe we should also have a variable like _shouldMouseLock. On pressing ESC we can set it to false, and it could trigger the unlock() method. We could use the same variable to trigger unlock when the browser/window/tab loses focus.
2 responses
Do you want to comment?
Comments RSS and TrackBack Identifier URI ?
Trackbacks