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


Java NativeMouseEvent类代码示例

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


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

示例1: GlobalMouseListener

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
public GlobalMouseListener() {
	mousePressed = new Function<NativeMouseEvent, Boolean>() {
		@Override
		public Boolean apply(NativeMouseEvent r) {
			return true;
		}
	};

	mouseReleased = new Function<NativeMouseEvent, Boolean>() {
		@Override
		public Boolean apply(NativeMouseEvent r) {
			return true;
		}
	};

	mouseMoved = new Function<NativeMouseEvent, Boolean>() {
		@Override
		public Boolean apply(NativeMouseEvent r) {
			return true;
		}
	};
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:23,代码来源:GlobalMouseListener.java

示例2: getMouseButtonCode

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
public static int getMouseButtonCode(int nativeCode, boolean isPressed) {
	if (isPressed) {
		if (nativeCode == NativeMouseEvent.BUTTON1_MASK) {
			return InputEvent.BUTTON1_DOWN_MASK;
		} else if (nativeCode == NativeMouseEvent.BUTTON2_MASK) {
			return InputEvent.BUTTON3_DOWN_MASK;
		} else if (nativeCode == NativeMouseEvent.BUTTON3_MASK) {
			return InputEvent.BUTTON2_DOWN_MASK;
		} else {
			return InputEvent.BUTTON1_DOWN_MASK;
		}
	} else {
		if (nativeCode == NativeMouseEvent.BUTTON1) {
			return InputEvent.BUTTON1_DOWN_MASK;
		} else if (nativeCode == NativeMouseEvent.BUTTON2) {
			return InputEvent.BUTTON3_DOWN_MASK;
		} else if (nativeCode == NativeMouseEvent.BUTTON3) {
			return InputEvent.BUTTON2_DOWN_MASK;
		} else {
			return InputEvent.BUTTON1_DOWN_MASK;
		}
	}
}
 
开发者ID:repeats,项目名称:Repeat,代码行数:24,代码来源:CodeConverter.java

示例3: run

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
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,代码行数:26,代码来源:GlobalScreen.java

示例4: processButtonEvent

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
/**
 * 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,代码行数:29,代码来源:GlobalScreen.java

示例5: processMouseEvent

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
/**
 * 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 NativeMouseMotionListener
 * @see #addNativeMouseMotionListener(NativeMouseMotionListener)
 */
private void processMouseEvent(NativeMouseEvent e) {
	NativeMouseMotionListener[] listeners = eventListeners.getListeners(NativeMouseMotionListener.class);

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

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

示例6: testProcessMouseEvent

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
/**
 * 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,代码行数:29,代码来源:GlobalScreenTest.java

示例7: nativeMouseWheelMoved

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
@Override
public void nativeMouseWheelMoved(NativeMouseWheelEvent event) {
	BioWheelEvent bioEvent = new BioWheelEvent();

	bioEvent.time = event.getWhen();
	bioEvent.rotation = event.getWheelRotation();
	bioEvent.amount = event.getScrollAmount();
	bioEvent.type = event.getScrollType();
	bioEvent.x = event.getX();
	bioEvent.y = event.getY();
	bioEvent.modifier_code = event.getModifiers();
	bioEvent.modifier_name = NativeMouseEvent.getModifiersText(
			event.getModifiers()).toLowerCase().replace(' ','_');

	mBuffer.addEvent(bioEvent);

	BioLogger.LOGGER.log(Level.INFO, "Mouse wheel, direction: " + bioEvent.rotation);
}
 
开发者ID:vmonaco,项目名称:biologger,代码行数:19,代码来源:Listener.java

示例8: nativeMouseDragged

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
@Override
public void nativeMouseDragged(NativeMouseEvent event) {
	BioMotionEvent bioEvent = new BioMotionEvent();

	bioEvent.time = event.getWhen();
	bioEvent.x = event.getX();
	bioEvent.y = event.getY();
	bioEvent.modifier_code = event.getModifiers();
	bioEvent.modifier_name = NativeMouseEvent.getModifiersText(
			event.getModifiers()).toLowerCase().replace(' ','_');
	bioEvent.dragged = 1;

	mBuffer.addEvent(bioEvent);

	BioLogger.LOGGER.info("Mouse dragged:: position: " + bioEvent.x + ", " + bioEvent.y);
}
 
开发者ID:vmonaco,项目名称:biologger,代码行数:17,代码来源:Listener.java

示例9: nativeMouseMoved

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
@Override
public void nativeMouseMoved(NativeMouseEvent event) {
	BioMotionEvent bioEvent = new BioMotionEvent();

	bioEvent.time = event.getWhen();
	bioEvent.x = event.getX();
	bioEvent.y = event.getY();
	bioEvent.modifier_code = event.getModifiers();
	bioEvent.modifier_name = NativeMouseEvent.getModifiersText(
			event.getModifiers()).toLowerCase().replace(' ','_');
	bioEvent.dragged = 0;

	mBuffer.addEvent(bioEvent);

	BioLogger.LOGGER.info("Mouse moved:: position: " + bioEvent.x + ", " + bioEvent.y);
}
 
开发者ID:vmonaco,项目名称:biologger,代码行数:17,代码来源:Listener.java

示例10: nativeMousePressed

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
@Override
public void nativeMousePressed(NativeMouseEvent event) {
	if (mActiveButtons.containsKey(event.getButton())) {
		return;
	}

	BioClickEvent bioEvent = new BioClickEvent();

	bioEvent.press_time = event.getWhen();
	bioEvent.button_code = event.getButton();
	bioEvent.modifier_code = event.getModifiers();
	bioEvent.modifier_name = NativeMouseEvent.getModifiersText(
			event.getModifiers()).toLowerCase().replace(' ','_');
	bioEvent.press_x = event.getX();
	bioEvent.press_y = event.getY();

	Rectangle capture = new Rectangle(event.getX() - CAPTURE_DELTA_X, event.getY() - CAPTURE_DELTA_Y,
			CAPTURE_DELTA_X * 2, CAPTURE_DELTA_Y * 2);
	bioEvent.image = Utility.screenCapture(capture);

	mActiveButtons.put(event.getButton(), bioEvent);

	BioLogger.LOGGER.info("Mouse pressed:: button: " + bioEvent.button_code + ", position: " + bioEvent.press_x
			+ ", " + bioEvent.press_y);
}
 
开发者ID:vmonaco,项目名称:biologger,代码行数:26,代码来源:Listener.java

示例11: dispatchEvent

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
/**
 * Dispatches an event to the appropriate processor.  This method is
 * generally called by the native library but maybe used to synthesize
 * native events from Java.
 *
 * @param e the <code>NativeInputEvent</code> to dispatch.
 */
public final void dispatchEvent(final NativeInputEvent e) {
	eventExecutor.execute(new Runnable() {
		public void run() {
			if (e instanceof NativeKeyEvent) {
				processKeyEvent((NativeKeyEvent) e);
			}
			else if (e instanceof NativeMouseWheelEvent) {
				processMouseWheelEvent((NativeMouseWheelEvent) e);
			}
			else if (e instanceof NativeMouseEvent) {
				processMouseEvent((NativeMouseEvent) e);
			}
		}
	});
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:23,代码来源:GlobalScreen.java

示例12: nativeMouseClicked

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
public void nativeMouseClicked(NativeMouseEvent e) {
	//            System.out.println("Mosue Clicked: " + e.getClickCount());

	
	ScreenRegion region = getRegionOfInterest();
	boolean isInsideROI = region.getBounds().contains(e.getX(), e.getY());			
	if (isInsideROI){
		
		ClickEvent event = new ClickEvent();
		event.setX(e.getX() - region.getBounds().x);
		event.setY(e.getY() - region.getBounds().y);		
		event.setButton(e.getButton());
		event.setClickCount(e.getClickCount());
		eventDetected(event);
	}
}
 
开发者ID:sikuli,项目名称:sikuli-slides,代码行数:17,代码来源:MouseEventDetector.java

示例13: nativeMouseReleased

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
@Override
public void nativeMouseReleased(NativeMouseEvent nativeEvent) {	
	// check if ctrl is pressed
	isCtrlKeyPressed = (nativeEvent.getModifiers() & NativeKeyEvent.CTRL_MASK) > 0;
	isAltKeyPressed = (nativeEvent.getModifiers() & NativeKeyEvent.ALT_MASK) > 0;
	popOverUI.hidePopOver();
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:8,代码来源:DropzonePopOver.java

示例14: nativeMouseDragged

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
@Override
public void nativeMouseDragged(NativeMouseEvent nativeEvent) {
	if (Util.isInActivationZone(nativeEvent)) {
		// trigger show popover
		popOverUI.showPopOver(false);
	}
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:8,代码来源:DropzonePopOver.java

示例15: getExtendedKeyCode

import org.jnativehook.mouse.NativeMouseEvent; //导入依赖的package包/类
/**
 * Gets the extended key code for this event, this key code
 * includes modifiers
 * @param event The event that occurred
 * @return The extended key code for this event
 */
private static final int getExtendedKeyCode(NativeInputEvent event){
	if(event instanceof NativeKeyEvent){
		return getExtendedKeyCode(((NativeKeyEvent)event).getKeyCode());
	}else{
		return -((NativeMouseEvent)event).getButton();
	}
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:14,代码来源:Main.java


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