문제

I'm trying to test by SWTBot hyperlinks inside my Eclipse's text editor. The problem is that the hyperlinks are shown on demand (an Eclipse feature), meaning - the token changes is revealed as hyperLink only when mouse moves over it + a keyboard key (Ctrl or Alt) is pressed.

How can I simulate in SWTBot the mouse-move together with a key pressed?

올바른 솔루션이 없습니다

다른 팁

When mouse moves over a link, then a MouseEvent is generated. Some MouseMotionListener (or maybe MouseListener) consumes this event and then shows hiperlink for you. You can simulate this event:

Component source = null; // TODO set up a valid component
    MouseEvent event = new MouseEvent(source, MouseEvent.MOUSE_ENTERED, System.currentTimeMillis(), InputEvent.ALT_DOWN_MASK, source.getX(), source.getY(), 0, false);
    MouseMotionListener[] mouseMotionListeners = source.getMouseMotionListeners();
    if (mouseMotionListeners!= null && mouseMotionListeners.length > 0) {
        MouseMotionListener mouseMotionListener = mouseMotionListeners[0];
        mouseMotionListener.mouseMoved(event);
    }

The InputEvent.ALT_DOWN_MASK in the constructor means that Alt is pressed. Note that you should define what Component responsible for consuming events in your case.

You can find more information in the tutorial How to Write a Mouse Listener and MouseEvent API

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top