Mouse-coordinates

NewB4a

Member
Licensed User
Longtime User
Hello,
with a mouse you can exactly get positions, i.e. for measuring movings or rotations, especially because you can simply plug the mouse via USB to a tablet and use it.
Is there also a simple way to get the actual (USB) mouse-coordinates with b4a?

Thanks
Tom
 

NewB4a

Member
Licensed User
Longtime User
Mouse (no help?)

Hello again and a more exact formulation of my problem:
I habe plugged a USB mouse ( better would be BT mouse) and I continously want to get the mousecoordinates when the mouse has been moved.
How to do this?

Thanks Tom
 
Upvote 0

NewB4a

Member
Licensed User
Longtime User
Coordinates without touch

Thanks Claus,
your example with touch runs. But my special problem: I want to get the coordinates without(!) touch. Probably a 'touchscreen' has for this purpose no possibilities, or..?

To explain the usage within a technical application: I have turned up a lasermouse, fixed it and move a plane(surface) above it, because I want to get the movements of this plane.

Any ideas for coordinates without touch?

Thanks
Tom
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, but I don't understand what exactly you want to do.

But on my Assus TF700 tablet I have a physical keyboard with touchpad.
The Touch event raised by both: screen touching and touchpad touching so I suppose it should also work with a mouse.

When you connect the mouse do you see a cursor on the screen ?
When I use the touchpad a cursor is dispayed on the screen.

Best regards.
 
Upvote 0

NewB4a

Member
Licensed User
Longtime User
In fact, I want to use the optical mouse only as an external sensor without any functionality on the touchpad itself. I need the tablet itself for making other (usual) actions.
After touching a button on the screen I want to read out the mouses coordinates that may vary due to a moving fixture/apparatus that moves upside the stationary fixed mouse.
The fact that the cursor is to be seen on the tablet is not of interest for me. Moreover I want to ensure that the touching actions do not interfere with the mouseposition which is relevant externally to the tablet surface.

I know that this is a very unusual application but for measurement purposes of movements laser-mice are the cheapest and most sensible interfaces.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Try this, the Listener changed in API14, so the attached lib provides OnGenericMotionListener for API 12 & 13, and OnHoverListener for Api14+.

It works on my Hydro X tablet, I don't have anything else to test it on though.

Download, unzip and copy the jar & xml file to your addl libs folder, in the libs tab, the library is called onHover.

The demo app just logs the throughput. ACTION_HOVER_MOVE is 7. 9 is ACTION_HOVER_ENTER,10 is ACTION_HOVER_EXIT.

Try it out and let me know if it works OK.
 

Attachments

  • onHover.zip
    5.9 KB · Views: 311
  • OnHoverLib.zip
    4.1 KB · Views: 292
Last edited:
Upvote 0

NewB4a

Member
Licensed User
Longtime User
Many thanks!!!!

Wonderful,
the example does exactly that, what I 've dreamed of. And: There is no reaction on touching the screen as wished. A great step for physicians and technicans using mouse as movement sensor.

Only one little wish, because I can't look inside the library: Can you explain the meaning of the action codes (as 9X), to let me know, what action has happened.

Your work saved (suppose not only for me) weeks of development time.
Tom
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi Tom, No problem.

The library is just a wrapper for the methods available in the View class, the documentation (linked) explains the Action Codes in detail, which are more obvious if you attach the listener to a view that covers part of the screen.

I attach the source for the library out of interest.
 

Attachments

  • onHover.zip
    911 bytes · Views: 248
Upvote 0

Piperni

Member
Licensed User
Longtime User
Hi,

Really a beginner here...still having problems to fully understand how to handle libraries, but I guess it will come with practice.

I am working on an application for someone with cerebral palsy, she can move her head (hence a mouse), but she pretty much cant click. I am developing simple applications for her, pretty much what I would like to do is to be able to detect that the mouse has moved over a view on the screen, without having to click on any button. So I am looking at allowing her to select a button just by bringing the mouse over it.

Anyone could write me a simple code for this in B4A?

Many thanks

Mike
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi Mike,

As promised here is an example using the above onHover library (Download from the link above and copy the xml and jar files to your addl libs directory) that will fire a button click when the button is entered with a mouse cursor as well as when the button is clicked manually.

You could use it to track the mouse over any view, but this example just has buttons.

For some reason (I don't know why) if you run it with the rapid debugger you will get two click events fired, but not in Legacy debugger, or release mode.

Hope it helps.

Steve
 

Attachments

  • OnHoverClick.zip
    6.3 KB · Views: 279
Upvote 0

Piperni

Member
Licensed User
Longtime User
Hi Steve, thank you so much, it works perfectly. Cant say I understand fully when it comes to using Java library...but I ll manage to use it and as I gain experience I ll probably become familiar.

Thanks again!
 
Upvote 0
Top