mirror of
https://github.com/glfw/glfw.git
synced 2025-04-11 19:32:02 +00:00
Merge 362915ead2
into 8f470597d6
This commit is contained in:
commit
5a9525f24f
@ -1759,6 +1759,31 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo
|
|||||||
*/
|
*/
|
||||||
typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
|
typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
|
||||||
|
|
||||||
|
/*! @brief The function pointer type for mouse button & position callbacks.
|
||||||
|
* This is the function pointer type for mouse button & position callback functions.
|
||||||
|
* A mouse button callback function has the following signature:
|
||||||
|
* @code
|
||||||
|
* void function_name(GLFWwindow* window, int button, int action, int mods, double xpos, double ypos)
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param[in] window The window that received the vent.
|
||||||
|
* @param[in] button The [mouse button](@ref buttons) that was pressed or
|
||||||
|
* released.
|
||||||
|
* @param[in] action One of 'GLFW_PRESS' or 'GLFW_RELEASE'. Future releases
|
||||||
|
* may add more actions.
|
||||||
|
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
|
||||||
|
* held down.
|
||||||
|
* @param[in] xpos The cursor x-position relative to the left edge of the
|
||||||
|
* content area.
|
||||||
|
* @param[in] xpos The cursor y-position relative to the right edge of the
|
||||||
|
* content area.
|
||||||
|
*
|
||||||
|
* @since Added in version 4.0
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWmousebuttonposfun)(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.
|
||||||
*
|
*
|
||||||
* This is the function pointer type for cursor position callbacks. A cursor
|
* This is the function pointer type for cursor position callbacks. A cursor
|
||||||
@ -5211,6 +5236,37 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
|
|||||||
*/
|
*/
|
||||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
|
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
|
||||||
|
|
||||||
|
/*! @brief Sets the mouse button & position callback.
|
||||||
|
*
|
||||||
|
* This function sets the mouse button and position callback of the specified window, which
|
||||||
|
* is called when a mouse button is pressed or released.
|
||||||
|
*
|
||||||
|
* For more information see the @ref glfwSetMouseButtonCallback.
|
||||||
|
*
|
||||||
|
* When the callback is called it also provides the cursor position relative
|
||||||
|
* to the window content area.
|
||||||
|
*
|
||||||
|
* @param[in] window The window whose callback to set.
|
||||||
|
* @param[in] callback The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @callback_signature
|
||||||
|
* @code
|
||||||
|
* void function_name(GLFWwindow* window, int button, int action, int mods, double xpos, double ypos)
|
||||||
|
* @endcode
|
||||||
|
* For more information about the callback parameters, see the
|
||||||
|
* [function pointer type](@ref GLFWmousebutonposfun).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWmousebuttonposfun glfwSetMouseButtonPosCallback(GLFWwindow* window, GLFWmousebuttonposfun callback);
|
||||||
|
|
||||||
/*! @brief Sets the cursor position callback.
|
/*! @brief Sets the cursor position callback.
|
||||||
*
|
*
|
||||||
* This function sets the cursor position callback of the specified window,
|
* This function sets the cursor position callback of the specified window,
|
||||||
|
13
src/input.c
13
src/input.c
@ -367,6 +367,8 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
|||||||
|
|
||||||
if (window->callbacks.mouseButton)
|
if (window->callbacks.mouseButton)
|
||||||
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
||||||
|
if (window->callbacks.mouseButtonPos)
|
||||||
|
window->callbacks.mouseButtonPos((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
|
||||||
@ -979,6 +981,17 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
|||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWmousebuttonposfun glfwSetMouseButtonPosCallback(GLFWwindow *handle,
|
||||||
|
GLFWmousebuttonposfun cbfun)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.mouseButtonPos, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||||
GLFWcursorposfun cbfun)
|
GLFWcursorposfun cbfun)
|
||||||
{
|
{
|
||||||
|
@ -562,6 +562,7 @@ struct _GLFWwindow
|
|||||||
GLFWframebuffersizefun fbsize;
|
GLFWframebuffersizefun fbsize;
|
||||||
GLFWwindowcontentscalefun scale;
|
GLFWwindowcontentscalefun scale;
|
||||||
GLFWmousebuttonfun mouseButton;
|
GLFWmousebuttonfun mouseButton;
|
||||||
|
GLFWmousebuttonposfun mouseButtonPos;
|
||||||
GLFWcursorposfun cursorPos;
|
GLFWcursorposfun cursorPos;
|
||||||
GLFWcursorenterfun cursorEnter;
|
GLFWcursorenterfun cursorEnter;
|
||||||
GLFWscrollfun scroll;
|
GLFWscrollfun scroll;
|
||||||
|
Loading…
Reference in New Issue
Block a user