i hava java swing application use 'pan-able' jcomponent display large data. when user move mouse wheel, listen these events, , update content of jcomponent scrolled amount.
i have different behavior depending on whether user is
- using classical mouse
- using touchpad, ones can found on modern mac laptops.
how detect user using mouse wheel vs trackpad generate scroll event? relying in java 1.6 swing, si cannot go javafx.
story behind question: wanted add cool inertia feel scrolling event when user use mouse wheel. of course, on macosx, trackpad has own inertia stuff builtin. wanted decide whether should generate inertial movement or not.
java swing old technology, supports traditional mouse wheel rotation events.
when use old wheel mouse, or wheel track-pad, read rotation of hardware wheel.
when use modern laser mouse, mouse movement translated rotation motion.
when use touch track-pad 1 in modern mac laptops, scroll gesture translated rotation motion, single & double touch left , right click (based on os mouse-pad configuration).
you can use libraries check input devices in detail, in case mouse or track-pad connected computer through usb, can try j-usb library.
as internal hardware, first have identify type of os, , based on can information on system , hardware in java.
finally, if application interacts user, suggest asking user type of mouse they're using, , store in configuration file or something.
Comments
Post a Comment