本文整理了Java中org.lwjgl.glfw.GLFW.glfwSetMouseButtonCallback()
方法的一些代码示例,展示了GLFW.glfwSetMouseButtonCallback()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwSetMouseButtonCallback()
方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwSetMouseButtonCallback
[英]Sets the mouse button callback of the specified window, which is called when a mouse button is pressed or released.
When a window loses input focus, it will generate synthetic mouse button release events for all pressed mouse buttons. You can tell these events from user-generated events by the fact that the synthetic ones are generated after the focus loss event has been processed, i.e. after the window focus callback has been called.
This function must only be called from the main thread.
[中]设置指定窗口的鼠标按钮回调,在按下或释放鼠标按钮时调用该回调。
当窗口失去输入焦点时,它将为所有按下的鼠标按钮生成合成鼠标按钮释放事件。您可以通过以下事实来区分这些事件与用户生成的事件:合成事件是在处理焦点丢失事件之后生成的,即在调用窗口焦点回调之后生成的。
只能从主线程调用此函数。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void initialize() {
glfwSetCursorPosCallback(context.getWindowHandle(), cursorPosCallback = new GLFWCursorPosCallback() {
@Override
public void invoke(long window, double xpos, double ypos) {
onCursorPos(window, xpos, ypos);
}
});
glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() {
@Override
public void invoke(final long window, final double xOffset, final double yOffset) {
onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE);
}
});
glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() {
@Override
public void invoke(final long window, final int button, final int action, final int mods) {
onMouseButton(window, button, action, mods);
}
});
setCursorVisible(cursorVisible);
logger.fine("Mouse created.");
initialized = true;
}
代码示例来源:origin: libgdx/libgdx
public void windowHandleChanged(long windowHandle) {
resetPollingStates();
GLFW.glfwSetKeyCallback(window.getWindowHandle(), keyCallback);
GLFW.glfwSetCharCallback(window.getWindowHandle(), charCallback);
GLFW.glfwSetScrollCallback(window.getWindowHandle(), scrollCallback);
GLFW.glfwSetCursorPosCallback(window.getWindowHandle(), cursorPosCallback);
GLFW.glfwSetMouseButtonCallback(window.getWindowHandle(), mouseButtonCallback);
}
代码示例来源:origin: libgdx/libgdx
public void windowHandleChanged(long windowHandle) {
resetPollingStates();
GLFW.glfwSetKeyCallback(window.getWindowHandle(), keyCallback);
GLFW.glfwSetCharCallback(window.getWindowHandle(), charCallback);
GLFW.glfwSetScrollCallback(window.getWindowHandle(), scrollCallback);
GLFW.glfwSetCursorPosCallback(window.getWindowHandle(), cursorPosCallback);
GLFW.glfwSetMouseButtonCallback(window.getWindowHandle(), mouseButtonCallback);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
glfwSetMouseButtonCallback(window, mouseButtonCallback = new GLFWMouseButtonCallback() {
@Override
public void invoke(final long window, final int button, final int action, final int mods) {
代码示例来源:origin: org.lwjgl.osgi/org.lwjgl.glfw
/** See {@link GLFW#glfwSetMouseButtonCallback SetMouseButtonCallback}. */
public GLFWMouseButtonCallback set(long window) {
glfwSetMouseButtonCallback(window, this);
return this;
}
代码示例来源:origin: playn/playn
public GLFWInput(LWJGLPlatform plat, long window) {
super(plat);
this.plat = plat;
this.window = window;
glfwSetCharCallback(window, charCallback);
glfwSetKeyCallback(window, keyCallback);
glfwSetMouseButtonCallback(window, mouseBtnCallback);
glfwSetCursorPosCallback(window, cursorPosCallback);
glfwSetScrollCallback(window, scrollCallback);
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: jsettlers/settlers-remake
private void registerCallbacks() {
GLFW.glfwSetKeyCallback(glfw_wnd, key_callback);
GLFW.glfwSetMouseButtonCallback(glfw_wnd, mouse_callback);
GLFW.glfwSetScrollCallback(glfw_wnd, scroll_callback);
GLFW.glfwSetCursorEnterCallback(glfw_wnd, cursorenter_callback);
GLFW.glfwSetCursorPosCallback(glfw_wnd, cursorpos_callback);
GLFW.glfwSetWindowSizeCallback(glfw_wnd, size_callback);
}
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: lwjglgamedev/lwjglbook
public void init(Window window) {
glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
currentPos.x = xpos;
currentPos.y = ypos;
});
glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
inWindow = entered;
});
glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
});
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3
public void windowHandleChanged(long windowHandle) {
resetPollingStates();
GLFW.glfwSetKeyCallback(window.getWindowHandle(), keyCallback);
GLFW.glfwSetCharCallback(window.getWindowHandle(), charCallback);
GLFW.glfwSetScrollCallback(window.getWindowHandle(), scrollCallback);
GLFW.glfwSetCursorPosCallback(window.getWindowHandle(), cursorPosCallback);
GLFW.glfwSetMouseButtonCallback(window.getWindowHandle(), mouseButtonCallback);
}
内容来源于网络,如有侵权,请联系作者删除!