Answered by:
How to capture Mouse prev/next buttons

Question
-
It seems that "MSPointerUp" does not tell me which button was released. "event.which" is always "1" and "event.button" always "0".
Any ideas how to capture the usually in IE used prev/next mouse buttons in a Metro style WinJS app?
Monday, April 23, 2012 3:02 PM
Answers
-
Phil,
Those are software driven buttons (you can program them). There is no provision (as far as I know) in javascript to trap buttons other than the standard right and left buttons.
Are you able to trap the right and left buttons in traditional javascript outside of metro? Even the W3C DOM event spec only mentions right and left buttons.
I did find MS exposes these buttons in down: http://msdn.microsoft.com/en-us/library/ie/ms533544(v=vs.85).aspx
What happens in your case (I only have 2 buttons and scroll), do you get an event for the other buttons?
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, April 24, 2012 8:09 PM
- Edited by Jeff SandersMicrosoft employee, Moderator Tuesday, April 24, 2012 8:18 PM
- Marked as answer by phil_ke Wednesday, May 2, 2012 2:30 PM
Tuesday, April 24, 2012 8:09 PMModerator
All replies
-
Hi Phil,
I don't follow you. What is a next and prev mouse button?
-Jeff
Jeff Sanders (MSFT)
Tuesday, April 24, 2012 1:19 PMModerator -
You should know... MSFT sells mice with those buttons.
They allow you (in the browser and Windows Explorer) to step back and forth in history.
Tuesday, April 24, 2012 1:33 PM -
Phil,
Those are software driven buttons (you can program them). There is no provision (as far as I know) in javascript to trap buttons other than the standard right and left buttons.
Are you able to trap the right and left buttons in traditional javascript outside of metro? Even the W3C DOM event spec only mentions right and left buttons.
I did find MS exposes these buttons in down: http://msdn.microsoft.com/en-us/library/ie/ms533544(v=vs.85).aspx
What happens in your case (I only have 2 buttons and scroll), do you get an event for the other buttons?
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, April 24, 2012 8:09 PM
- Edited by Jeff SandersMicrosoft employee, Moderator Tuesday, April 24, 2012 8:18 PM
- Marked as answer by phil_ke Wednesday, May 2, 2012 2:30 PM
Tuesday, April 24, 2012 8:09 PMModerator -
hmmmm... IE and Windows Explorer are able to capture them.
Maybe I would have to write a WinRT component to capture them and emit the events to JS myself?
Tuesday, April 24, 2012 9:24 PM -
Great, just use the same javascript you are using in IE and you should be good!
Jeff Sanders (MSFT)
Wednesday, April 25, 2012 12:07 PMModerator -
What I meant was, that IE and Windows Explorer are probably using the WM_* mouse messages to detect those clicks on the mouse navigation buttons. So I would assume that they also send over those buttons to JS. Unfortunately that's not that case. It would be really helpful if we could use these buttons to navigate through WinJS apps as well.
I know "touch first" but we should ensure a good mouse navigation as well.
Wednesday, May 2, 2012 11:14 AM -
Hi Phil,
Could be, or it might software map to keys like backspace. Let me see what I can find out with process explorer or Spy++ (just found an old mouse with a back button).
-Jeff
Jeff Sanders (MSFT)
Wednesday, May 2, 2012 11:37 AMModerator -
Hi Phil,
http://msdn.microsoft.com/en-us/library/ms997498.aspx
These buttons map to WM_APPCOMMAND (or xbutton) and this is not reflected in the Javascript engine.
Sadly there is no way to grab the WinProc or anything like that in JavaScript so you will not be able to handle these buttons in your app.
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Wednesday, May 2, 2012 2:10 PM
Wednesday, May 2, 2012 2:10 PMModerator -
Thanks Jeff for your efforts. Sad news though. Maybe you can forward this request to the WinRT people and they introduce a special WinRT event just like the "MSPointerDown" custom events already there. It would make the navigation via mouse much easier for all of us.
Then this functionality could be incorporated into the template "navigator.js" which already handles navigation via arrow keys.
Wednesday, May 2, 2012 2:29 PM -
I tried the mousedown event but it had the "button" value set to "0" when I clicked the navigation buttons on the mouse.Wednesday, May 2, 2012 2:31 PM
-
Hi all,
Do the RTM finally provide such component?
I totally agree with Phil that WinJS should handle it automatically via the navigator.
Friday, October 5, 2012 1:18 PM -
Yes, it has been fixed 2 versions ago. Sorry for not updating this post. The default navigator now handles keyboard and mouse navigation perfectly.Friday, October 5, 2012 1:40 PM
-
Hi .. I am trying to figure how the values 1 4 2 are popping up for the mouse left,middle,right click events. we are getting the values like left click 5 and right click 6 in a particular machine.
Is it some thing to do with the registry set up? or mouse driver set up ? which make this to respond wierd like this?
Thanks, Hari.A
Tuesday, October 16, 2012 3:54 PM -
The values are added together. So for example 5 means the left and middle and 6 would be the right and middle. Yes this could have something to do with the mouse software installed.
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Tuesday, October 16, 2012 6:05 PM
Tuesday, October 16, 2012 6:05 PMModerator -
Actually we have disabled the right click in our site by having the login window.event>1 from our Application.
I have tested the mouse button events by a simple java script which returned 1 2 for left and right button click. But when I am testing it from my application it returns 5, 7 for left and right button click. Any idea how this is happening?
Due to this different behavior user is getting the right click disabled message irrespective of the Right/Left button click on mouse. Desktop team did format the machine and reinstalled everything still facing the same issue in that particular only one machine.
Any idea to fix this issue and prove this is not our application issue? its a issue with the local machine hardware setting/driver software issue?
It would be helpful if we know how the values (on left click its 1) are derived? on what basis this is set up? is it some setting kind of stuff on reg edit or driver?
Thanks, Hari.A
- Edited by Hari_aindian Saturday, October 20, 2012 10:09 AM Added note on the application behavior
Tuesday, October 16, 2012 6:23 PM