• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it a 3 or 2 button mouse?

 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to programmically tell if you're using a 2 or 3 button mouse? I haven't seen anything, but I'm hoping I'm just not looking in the right places.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the real question you need answered may be "Does java treat 2-button and 3-button mice the same".
Left click is assigned BUTTON1. I think right click is assigned BUTTON3, leaving BUTTON2 for a middle click if you have one. I have to say I haven't tested this with a 2 button mouse, but I'm sure they dealt with this matter when they were setting up the MouseListeners.
Easiest thing to do is to take some code written to listen for right click specificly and hook up an old 2 button mouse to your PC to test it.
If I get a chance, I will test it myself and post the results here. I have an app I have been working on that uses right clicks and works fine with my wheel mouse(push the wheel for middle click). I guess I need to double check this anyways unless someone knows for sure and can post it here.
Now I'm using java 1.4, so if you are using something earlier than that, there may be a difference. I know they changed a few things in the MouseEvent object since 1.3.
[ June 20, 2002: Message edited by: Chris Shepherd ]
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what I've tried the 2 button mouse returns 1+3 when both mouse buttons are clicked. While on the 3 button mouse button 2 can be pressed.
The reason I'd like to know if its a 2 or 3 button mouse is because on a two button mouse 1+3 needs to be interpretted as the middle button, while on the 3 button mouse 1+3 needs to be intrepretted as actions for button 1 and 3.
I've got requirements on what actions should be taken for the mouse buttons, so I can't change them.
I really do want to know if it is a 2 or 3 button mouse. I can work around not knowing, but I think the best solution would be to know which I'm working with.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, I'm not sure you'r going to be able to get that info. Why not just make 1+3 always center click? That or have a user option of making 1+3 a middle click (hey look, its a feature now.. ). If you make it user defineable, then the burden is off you to try and detect it.
If someone says something about it not being automaticly set, just point out to them that some users might rather have the option on even for 3 button mice. Plus this will save money cause you didn't have to spend lots of time glueing lots of clumsy tests together to try and detect whether they have a middle mouse button.
If you HAVE to detect, could you ask the user to click his middle mouse button if he has one? Do that once and then save the results somewhere and you'd never have to ask again for that machine.
It really comes down to the drivers on the machine, not the mouse itself. Some drivers already have the built-in middle click when you press both buttons. You would almost have to query the driver in some way, and that would be very bad. Too many drivers out there to adapt to them all.
Hope something in here helps out.
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that helps out.
I'd really like a nice way to tell. So what I've done is default to 3 mouse button mode, and the user has an option to change it to 2 button mode.
This is for a 3D application, zooming, rotating etc. and they want the mouse to drive the display in the same manner as some other application the user's use. Most of them have 3 button mice, but there are still a few 2 button mice.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would work. Hey, what about defaulting to the 2 button and listen for a true middle mouse click. First time you see one you set everything in the 3 button mode and forget about it. Otherwise it just runs in the 2 button mode.
Heh, or offer a 3 button mouse when you send them the software...
[ June 20, 2002: Message edited by: Chris Shepherd ]
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!