Android-Simulate mouseover/hover - java

How can you simulate a mouseover event in an android app?
I have to detect if the user is touching/hovering over a particular part of the screen for more than 2 seconds.

you cant hover without a cursor.
but for an ipad there is a simulate hover command for css. unfortently i cant find it, if anyone does find it let me know!
i used it in some code once, im scouring that code for it, im hoping i didnt imagine it.

Case: I wanted a pointer to move a mouse around the screen of my phone via my watch. If somebody finds this in the future:
Pointer image: Tasker allows to create scenes. Create a scene with a canvas as big as you want your pointer to be, add the image you want as pointer as the scene only element, filling the scene.
Coordinates static: Create variables for "X" and "Y" (these are STILL NOT pixels). You want to play around with values on the show scene location applying your variables. 0,0 is top left, 200,200 is bottom right.
Coordinates movement: My approach was having 2 variables "now" and "final" (or other names). So you can tell tasker: Hide scene in Xnow,Ynow; Show scene in Xfinal,Yfinal; Set variables Xnow to Xfinal and Ynow to Yfinal.
With that in mind:
You may want to detect if "mouse overlay image is on top of your desired element.

With a touch screen, users can only touch or not touch, but not hover, so that this part of the question is probably out.
The long touch behavior is implemented inside the various onXXXLongClick() handlers.

How to hover over a link?
I hope this link helps you .
But how can a person hover in a touch device ? Well i have always placed my fingers .

Try adding onClick="return true" in your link a href tag
About us
the onClick="return true" should simulate a cursor hovering over then leaving the hover area. effectivly giving you a hover effect.
keep in mind, ur finger has to touch the button for the hover effect to take place, which means the user will only see the change for a second or two before the link loads a page.

Related

GEF : automatic scrolling during drag and drop

I have a graphical editor written with GEF. In this editor it's possible to drag and drop elements around and create connection by dragging and dropping on specific anchor points.
Everything works fine, except that the diagram does not automatically scroll when the user drags stuff around.
I would expect the diagram to scroll automatically when the user reaches the side of it while dragging something.
Is such a feature supported by GEF? Which class/setter should be called to enable it?
If it's not directly supported, how to proceed to achieve it?
It's been a while since I last fiddled with GEF.
Does drag and drop not work at all or just in the direction of negative coordinates?
What Layout are you using?
IIRC, there were different layouts with one of them (FreeForm?) supporting negative coordinates, so if you just have trouble with negative coords, you could try to change the Layout.
Here is an example of a Scrolling Graphical editor (the author says ;)) which might give you a good hint.
And there is a class named org.eclipse.gef.ui.parts.ScrollingGraphicalViewer that might help, too.
Only hints, though, since I don't know your code.
First step is to make your canvas scrollable. This is explained in this book, pages 96 - 101.
Assuming you are already drawing your figures on a FigureCanvas and you're using FreeformFigures and FreeformLayer, you can do the following:
Add a MouseMoveListener on your Figure in its EditPart. Each time a drag is detected, in the mouseDragEvent method, reveal your figure with getViewer().reveal(EditPart.this).
This will cause your Figure to always be constantly revealed when it's being dragged.

Swap mouse buttons in java application

I'm using a dynamic graphic library to display data. By clicking with the left button on a node, a window pops out displaying info about it. I would like to use the right button instead, which by now is used to move the node around (without the window popping out). The problem is: the graph listeners I'm using only respond to the left button. So the only solution I can think of is to swap the mouse buttons mapping on the java application. Is there a way to achieve this?
I might be wrong, but can you use MouseListeners for right click, and than use java.awt.Robot to left click that? just a thought. good luck.
Whoops, sorry. I already solved this a long time ago and I forgot to post the answer: The library I'm using is graphstream, and I just needed to set the graph DefaultMouseManagerm (with overriden functions) which takes care of mouse clicks on the graph.

Eclipse direct shortcut instead of yellow popup?

How do I remove this middle step of having to press enter after F12 to make the actual navigation? I don't need this yellow popup telling me there's one shortcut for me.
In the second image you can see the problem: I want F12 to immediate open up the definition / declaration of the symbol my cursor is currently at. Need it for Java.
Have you tried to hover over the type/method with your mouse then hold ctrl and left mouse click.
It's a default shortcut in eclipse.
edit: sorry this should have been a comment to your question, not an answer.
The problem was indeed multiple bindings for the same key.

Swing - Changing the content of a panel using UpdateUI

I am going through a legacy application which is using Swing and i am struggling to figure out how the screens are changing when a user clicks a button. One of the reasons i cant figure this out is because this is the first time i am using Swing. I have read a book and got the basics but still struggling.
Basically, the screen i am looking at has a JSplitPane which has a number of shortcut buttons on the left and an empty pane on the right. When i click on the button, the right side pane is populated with a different screen depending on the button pressed.
Going through the code, i was expecting somewhere that there will be something that calls a setVisible() method depending on which button is pressed.
The actionPerformed method for each of the shortcut buttons looks something like this:
void shortCutBtn_actionPerformed(ActionEvent e) {
propertyChangeListeners.firePropertyChange("selectedShortCut", previousShortCutSel, currentShortCutSel);
mainPanel.updateUI();
}
I have gone through most of the code and came to a conclusion that the above code is what is causing the frame switching but i dont understand how that is happening.
Each screen is identified by a numeric constant. In the above code example, previousShortCutSel and previousShortCutSel refer to a numeric value that represents individual screens screen.
I have tried to look for documentation of how updateUI() works but i am lost. How does the above cause the content of the right panel of the JSplitPanel to be updated with a new screen?
This is not an appropriate use of updateUI(), which "Resets the UI property to a value from the current look and feel." As the example itself may be unreliable, consider studying another. GoogleOlympiad, for example, sets a label's icon using a (cached) image.
ImageIcon image = getImage(index);
imageLabel.setIcon(image);
(source: drjohnbmatthews at sites.google.com)
As per comments by ziggy (glad it helped)
Have a look at the PropertyChangeListeners that appear to be added in the code. In particular the propertyChange(PropertyChangeEvent e) method is where the code which changes the content will be present.
+1 to trashgod nice example/advice as always

Press buttons without release finger from screen

I want to press buttons like it shown on this picture http://i.stack.imgur.com/C1NW3.jpg. That is I want to press buttons by holding finger on the screen and moving it along buttons. For example on this pic buttons 1, 2,5,8,9 will be pressed after this procedure.
Sorry for my bad english, but i cant to describe this in a different way.
How I can do this?
Well, sorry for not providing the very simple answer like "use the function xyz()" for this, but I think there are some general ways to do it:
You can create pictures that look like buttons (or bubbles or anything else appropriate), place them in an order that you need and then, getting each coordinate of the pointer (of the finger) on the screen, just check if this pointer gets into some area (maybe rectangle) inside each button. This logical area should be smaller than shown picture to let user move finger not so careful.
Another "solution" would be to put some "jitter" and send "left click" message on each position update along the way. In this case buttons should have some protection from multiple clicks. I remember on stackoverflow.com some advice how to do this: just disable the button on the click event.
Sorry if Android has some solution "out of the box", which I have no idea about, but the described problem seems to be general, not platform-specific.

Categories