当前位置: 首页>>代码示例>>Java>>正文


Java NativeMouseEvent.NATIVE_MOUSE_CLICKED属性代码示例

本文整理汇总了Java中org.jnativehook.mouse.NativeMouseEvent.NATIVE_MOUSE_CLICKED属性的典型用法代码示例。如果您正苦于以下问题:Java NativeMouseEvent.NATIVE_MOUSE_CLICKED属性的具体用法?Java NativeMouseEvent.NATIVE_MOUSE_CLICKED怎么用?Java NativeMouseEvent.NATIVE_MOUSE_CLICKED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.jnativehook.mouse.NativeMouseEvent的用法示例。


在下文中一共展示了NativeMouseEvent.NATIVE_MOUSE_CLICKED属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

public void run() {
	if (event instanceof NativeKeyEvent) {
		processKeyEvent((NativeKeyEvent) event);
	}
	else if (event instanceof NativeMouseWheelEvent) {
		processMouseWheelEvent((NativeMouseWheelEvent) event);
	}
	else if (event instanceof NativeMouseEvent) {
		switch (event.getID()) {
			case NativeMouseEvent.NATIVE_MOUSE_PRESSED:
			case NativeMouseEvent.NATIVE_MOUSE_CLICKED:
			case NativeMouseEvent.NATIVE_MOUSE_RELEASED:
				processButtonEvent((NativeMouseEvent) event);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_MOVED:
			case NativeMouseEvent.NATIVE_MOUSE_DRAGGED:
				processMouseEvent((NativeMouseEvent) event);
				break;
		}
	}
	else if (event instanceof NativeMouseWheelEvent) {
		processMouseWheelEvent((NativeMouseWheelEvent) event);
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:25,代码来源:GlobalScreen.java

示例2: processButtonEvent

/**
 * Processes native mouse button events by dispatching them to all registered
 * <code>NativeMouseListener</code> objects.
 *
 * @param e the <code>NativeMouseEvent</code> to dispatch.
 * @see NativeMouseEvent
 * @see NativeMouseListener
 * @see #addNativeMouseListener(NativeMouseListener)
 */
private void processButtonEvent(NativeMouseEvent e) {
	NativeMouseListener[] listeners = eventListeners.getListeners(NativeMouseListener.class);

	for (int i = 0; i < listeners.length; i++) {
		switch (e.getID()) {
			case NativeMouseEvent.NATIVE_MOUSE_CLICKED:
				listeners[i].nativeMouseClicked(e);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_PRESSED:
				listeners[i].nativeMousePressed(e);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_RELEASED:
				listeners[i].nativeMouseReleased(e);
				break;
		}
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:28,代码来源:GlobalScreen.java

示例3: testProcessMouseEvent

/**
 * Test of processMouseEvent method, of class GlobalScreen.
 */
@Test
public void testProcessMouseEvent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InterruptedException {
	System.out.println("processMouseEvent");

	// Setup and event listener.
	NativeMouseInputListenerImpl listener = new NativeMouseInputListenerImpl();
	GlobalScreen.addNativeMouseListener(listener);

	// Dispatch a mouse event and check to see if it was sent.
	NativeMouseEvent event = new NativeMouseEvent(
			NativeMouseEvent.NATIVE_MOUSE_CLICKED,
			0x00,	// Modifiers
			50,		// X
			75,		// Y
			1,		// Click Count
			NativeMouseEvent.BUTTON1);

	synchronized (listener) {
		GlobalScreen.dispatchEvent(event);
		listener.wait(3000);
		assertEquals(event, listener.getLastEvent());
	}

	GlobalScreen.removeNativeMouseListener(listener);
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:28,代码来源:GlobalScreenTest.java

示例4: nativeMouseClicked

public void nativeMouseClicked(NativeMouseEvent e) {
	System.out.println("Received " + e.paramString());

	if (e.getID() != NativeMouseEvent.NATIVE_MOUSE_CLICKED) {
		throw new IllegalArgumentException("Invalid event type received for nativeMouseClicked!");
	}

	lastEvent = e;

	synchronized(this) {
		this.notifyAll();
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:13,代码来源:NativeMouseInputListenerImpl.java

示例5: processMouseEvent

/**
 * Processes native mouse events by dispatching them to all registered
 * <code>NativeMouseListener</code> objects.
 *
 * @param e the <code>NativeMouseEvent</code> to dispatch.
 * @see NativeMouseEvent
 * @see NativeMouseListener
 * @see #addNativeMouseListener(NativeMouseListener)
 */
protected void processMouseEvent(NativeMouseEvent e) {
	int id = e.getID();

	EventListener[] listeners;
	if (id == NativeMouseEvent.NATIVE_MOUSE_MOVED || id == NativeMouseEvent.NATIVE_MOUSE_DRAGGED) {
		listeners = eventListeners.getListeners(NativeMouseMotionListener.class);
	}
	else {
		listeners = eventListeners.getListeners(NativeMouseListener.class);
	}

	for (int i = 0; i < listeners.length; i++) {
		switch (id) {
			case NativeMouseEvent.NATIVE_MOUSE_CLICKED:
				((NativeMouseListener) listeners[i]).nativeMouseClicked(e);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_PRESSED:
				((NativeMouseListener) listeners[i]).nativeMousePressed(e);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_RELEASED:
				((NativeMouseListener) listeners[i]).nativeMouseReleased(e);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_MOVED:
				((NativeMouseMotionListener) listeners[i]).nativeMouseMoved(e);
				break;

			case NativeMouseEvent.NATIVE_MOUSE_DRAGGED:
				((NativeMouseMotionListener) listeners[i]).nativeMouseDragged(e);
				break;
		}
	}
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:44,代码来源:GlobalScreen.java

示例6: testDispatchEvent

/**
 * Test of dispatchEvent method, of class GlobalScreen.
 */
@Test
public void testDispatchEvent() throws InterruptedException, NativeHookException {
	System.out.println("dispatchEvent");

	// Setup and event listener.
	NativeKeyListenerImpl keyListener = new NativeKeyListenerImpl();
	GlobalScreen.addNativeKeyListener(keyListener);

	NativeMouseInputListenerImpl mouseListener = new NativeMouseInputListenerImpl();
	GlobalScreen.addNativeMouseListener(mouseListener);

	NativeMouseWheelListenerImpl wheelListener = new NativeMouseWheelListenerImpl();
	GlobalScreen.addNativeMouseWheelListener(wheelListener);

	// Make sure the native thread is running!
	GlobalScreen.registerNativeHook();

	// Dispatch a key event and check to see if it was sent.
	NativeKeyEvent keyEvent = new NativeKeyEvent(
			NativeKeyEvent.NATIVE_KEY_PRESSED,
			0x00,		// Modifiers
			0x41,		// Raw Code
			NativeKeyEvent.VC_A,
			NativeKeyEvent.CHAR_UNDEFINED,
			NativeKeyEvent.KEY_LOCATION_STANDARD);

	synchronized (keyListener) {
		GlobalScreen.dispatchEvent(keyEvent);
		keyListener.wait(3000);
		assertEquals(keyEvent, keyListener.getLastEvent());
	}


	// Dispatch a mouse event and check to see if it was sent.
	NativeMouseEvent mouseEvent = new NativeMouseEvent(
			NativeMouseEvent.NATIVE_MOUSE_CLICKED,
			0x00,	// Modifiers
			50,		// X
			75,		// Y
			1,		// Click Count
			NativeMouseEvent.BUTTON1);

	synchronized (mouseListener) {
		GlobalScreen.dispatchEvent(mouseEvent);
		mouseListener.wait(3000);
		assertEquals(mouseEvent, mouseListener.getLastEvent());
	}

	// Dispatch a mouse event and check to see if it was sent.
	NativeMouseWheelEvent wheelEvent = new NativeMouseWheelEvent(
			NativeMouseEvent.NATIVE_MOUSE_WHEEL,
			0x00,	// Modifiers
			50,		// X
			75,		// Y
			1,		// Click Count
			NativeMouseWheelEvent.WHEEL_UNIT_SCROLL,
			3,		// Scroll Amount
			-1);	// Wheel Rotation

	synchronized (wheelListener) {
		GlobalScreen.dispatchEvent(wheelEvent);
		wheelListener.wait(3000);
		assertEquals(wheelEvent, wheelListener.getLastEvent());
	}

	// Stop the native thread.
	GlobalScreen.unregisterNativeHook();

	// Remove all added listeners.
	GlobalScreen.removeNativeKeyListener(keyListener);
	GlobalScreen.removeNativeMouseListener(mouseListener);
	GlobalScreen.removeNativeMouseWheelListener(wheelListener);
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:76,代码来源:GlobalScreenTest.java


注:本文中的org.jnativehook.mouse.NativeMouseEvent.NATIVE_MOUSE_CLICKED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。