Add mouse position to mouse button callback

Adds the current mouse position as parameters to the mouse button
callback. This is to aid in handling mouse button events properly.

Resolves: #752
This commit is contained in:
Joshua Woodie 2021-10-09 15:23:38 -04:00
parent 6ed5294223
commit b6efafdf6e
2 changed files with 6 additions and 2 deletions

View File

@ -1684,6 +1684,10 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo
* may add more actions. * may add more actions.
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
* held down. * held down.
* @param[in] xpos The x-coordinate of the cursor, relative to the left edge of
* the content area.
* @param[in] ypos The y-coordinate of the cursor, relative to the top edge of
* the content area.
* *
* @sa @ref input_mouse_button * @sa @ref input_mouse_button
* @sa @ref glfwSetMouseButtonCallback * @sa @ref glfwSetMouseButtonCallback
@ -1693,7 +1697,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo
* *
* @ingroup input * @ingroup input
*/ */
typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods); typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods, double xpos, double ypos);
/*! @brief The function pointer type for cursor position callbacks. /*! @brief The function pointer type for cursor position callbacks.
* *

View File

@ -336,7 +336,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
window->mouseButtons[button] = (char) action; window->mouseButtons[button] = (char) action;
if (window->callbacks.mouseButton) if (window->callbacks.mouseButton)
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods); window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods, window->virtualCursorPosX, window->virtualCursorPosY);
} }
// Notifies shared code of a cursor motion event // Notifies shared code of a cursor motion event