當前位置: 首頁>>代碼示例>>Java>>正文


Java GlobalScreen.addNativeMouseWheelListener方法代碼示例

本文整理匯總了Java中org.jnativehook.GlobalScreen.addNativeMouseWheelListener方法的典型用法代碼示例。如果您正苦於以下問題:Java GlobalScreen.addNativeMouseWheelListener方法的具體用法?Java GlobalScreen.addNativeMouseWheelListener怎麽用?Java GlobalScreen.addNativeMouseWheelListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jnativehook.GlobalScreen的用法示例。


在下文中一共展示了GlobalScreen.addNativeMouseWheelListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setOnScrollListener

import org.jnativehook.GlobalScreen; //導入方法依賴的package包/類
/**
 * Enables handling of scroll and mouse wheel events for the node.
 * This type of events has a peculiarity on Windows. See the javadoc of notifyScrollEvents for more information.
 * @see #notifyScrollEvent
 * @param intersectionTestFunc a function that takes an event object and must return boolean
 * @return itself to let you use a chain of calls
 */
MouseEventNotificator setOnScrollListener(Function<NativeMouseWheelEvent, Boolean> intersectionTestFunc) {
    if (SystemUtils.IS_OS_WINDOWS) {
        if (!GlobalScreen.isNativeHookRegistered()) {
            try {
                GlobalScreen.registerNativeHook();
            } catch (NativeHookException | UnsatisfiedLinkError e) {
                e.printStackTrace();
                Main.log("Failed to initialize the native hooking. Rolling back to using JavaFX events...");
                sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
                return this;
            }
        }
        mouseWheelListener = event -> notifyScrollEvent(event, intersectionTestFunc);
        GlobalScreen.addNativeMouseWheelListener(mouseWheelListener);
    } else {
        sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
    }

    return this;
}
 
開發者ID:DeskChan,項目名稱:DeskChan,代碼行數:28,代碼來源:MouseEventNotificator.java

示例2: initGlobalListeners

import org.jnativehook.GlobalScreen; //導入方法依賴的package包/類
private void initGlobalListeners() {
    // Initialze native hook.
    try {
        GlobalScreen.registerNativeHook();
    }
    catch (NativeHookException ex) {
        System.err.println("There was a problem registering the native hook.");
        System.err.println(ex.getMessage());
        ex.printStackTrace();
        System.exit(1);
    }
    detectKeys = new DetectKeys(this, keyLabel, shift, ctrl, alt, mouseLabel, mouseImages);
    GlobalScreen.addNativeKeyListener(detectKeys);
    GlobalScreen.addNativeMouseWheelListener(detectKeys);
    GlobalScreen.addNativeMouseListener(detectKeys);
}
 
開發者ID:CorpWar,項目名稱:keycast,代碼行數:17,代碼來源:Keycast.java

示例3: main

import org.jnativehook.GlobalScreen; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException
{
	disableLogging();
	try
	{
		GlobalScreen.registerNativeHook();
	}
	catch (NativeHookException ex)
	{
		System.err.println("There was a problem registering the native hook.");
		System.err.println(ex.getMessage());

		System.exit(1);
	}

	GlobalMouseListener globalMouseListener = new GlobalMouseListener();
	GlobalScreen.addNativeMouseListener(globalMouseListener);
	GlobalScreen.addNativeMouseMotionListener(globalMouseListener);
	GlobalScreen.addNativeMouseWheelListener(globalMouseListener);
	GlobalScreen.addNativeKeyListener(new GlobalKeyListener());
}
 
開發者ID:tomzx,項目名稱:gkm-java,代碼行數:22,代碼來源:GlobalListener.java

示例4: startLogging

import org.jnativehook.GlobalScreen; //導入方法依賴的package包/類
public void startLogging() {

		try {
			GlobalScreen.registerNativeHook();
		} catch (NativeHookException e) {
			BioLogger.LOGGER.severe("There was a problem registering the native hook.");
			if (System.getProperty("os.name").toLowerCase().contains("mac")) {
				BioLogger.LOGGER.severe("Make sure that Assistive Devices is enabled.");
				BioLogger.LOGGER.severe(
						"Go to System Preferences->Security & Privacy->Accessibility");
			}
			e.printStackTrace();
			return;
		}

		if (mClassMap.containsKey(BioKeystrokeEvent.class)) {
			GlobalScreen.addNativeKeyListener(mListener);
		}

		if (mClassMap.containsKey(BioClickEvent.class)) {
			GlobalScreen.addNativeMouseListener(mListener);
		}

		if (mClassMap.containsKey(BioMotionEvent.class)) {
			GlobalScreen.addNativeMouseMotionListener(mListener);
		}

		if (mClassMap.containsKey(BioWheelEvent.class)) {
			GlobalScreen.addNativeMouseWheelListener(mListener);
		}
	}
 
開發者ID:vmonaco,項目名稱:biologger,代碼行數:32,代碼來源:BioLogger.java

示例5: register

import org.jnativehook.GlobalScreen; //導入方法依賴的package包/類
private void register() {
	GlobalScreen.addNativeMouseListener(this);
	GlobalScreen.addNativeMouseMotionListener(this);
	GlobalScreen.addNativeMouseWheelListener(this);
}
 
開發者ID:GamesRythmAnalysis,項目名稱:RNGames,代碼行數:6,代碼來源:MouseListener.java

示例6: itemStateChanged

import org.jnativehook.GlobalScreen; //導入方法依賴的package包/類
/**
 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
 */
public void itemStateChanged(ItemEvent e) {
	ItemSelectable item = e.getItemSelectable();

	if (item == menuItemEnable) {
		try {
			// Keyboard checkbox was changed, adjust listeners accordingly.
			if (e.getStateChange() == ItemEvent.SELECTED) {
				// Initialize native hook.  This is done on window open because the
				// listener requires the txtEventInfo object to be constructed.
				GlobalScreen.registerNativeHook();
			}
			else {
				GlobalScreen.unregisterNativeHook();
			}
		}
		catch (NativeHookException ex) {
			txtEventInfo.append("Error: " + ex.getMessage() + "\n");
		}

		// Set the enable menu item to the state of the hook.
		menuItemEnable.setState(GlobalScreen.isNativeHookRegistered());

		// Set enable/disable the sub-menus based on the enable menu item's state.
		menuSubListeners.setEnabled(menuItemEnable.getState());
	}
	else if (item == menuItemKeyboardEvents) {
		// Keyboard checkbox was changed, adjust listeners accordingly
		if (e.getStateChange() == ItemEvent.SELECTED) {
			GlobalScreen.addNativeKeyListener(this);
		}
		else {
			GlobalScreen.removeNativeKeyListener(this);
		}
	}
	else if (item == menuItemButtonEvents) {
		// Button checkbox was changed, adjust listeners accordingly
		if (e.getStateChange() == ItemEvent.SELECTED) {
			GlobalScreen.addNativeMouseListener(this);
		}
		else {
			GlobalScreen.removeNativeMouseListener(this);
		}
	}
	else if (item == menuItemMotionEvents) {
		// Motion checkbox was changed, adjust listeners accordingly
		if (e.getStateChange() == ItemEvent.SELECTED) {
			GlobalScreen.addNativeMouseMotionListener(this);
		}
		else {
			GlobalScreen.removeNativeMouseMotionListener(this);
		}
	}
	else if (item == menuItemWheelEvents) {
		// Motion checkbox was changed, adjust listeners accordingly
		if (e.getStateChange() == ItemEvent.SELECTED) {
			GlobalScreen.addNativeMouseWheelListener(this);
		}
		else {
			GlobalScreen.removeNativeMouseWheelListener(this);
		}
	}
}
 
開發者ID:kwhat,項目名稱:jnativehook,代碼行數:66,代碼來源:NativeHookDemo.java


注:本文中的org.jnativehook.GlobalScreen.addNativeMouseWheelListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。