wjakob / nanogui

Minimalistic GUI library for OpenGL
Other
4.66k stars 608 forks source link

MouseState as button #70

Open RobotCaleb opened 8 years ago

RobotCaleb commented 8 years ago

At https://github.com/wjakob/nanogui/blob/master/src/screen.cpp#L443 mMouseState is passed to mouseDragEvent(), which has a prototype of bool mouseDragEvent(const Vector2i &p, const Vector2i &rel, int button, int modifiers). Note that parameter is called button, not state.

mMmouseState isn't a button, which causes any code that tries to inspect it (say, in the case where the constraint on a drag action requiring mouse button 1 (https://github.com/wjakob/nanogui/blob/master/src/screen.cpp#L488) has been removed) to get the wrong value due to the actual button not being passed.

wjakob commented 8 years ago

The user might press multiple buttons, so passing the state generally seems like the right way to go. What about renaming the parameter from "button" to "buttonState" or something like that?

RobotCaleb commented 8 years ago

Mouse drag event is currently constrained to kick in on just one button. In that case, pushing the state at all seems a bit of a fallacy. That is, checking the state doesn't provide any information with meaning.

Unfortunately, I'm not offering a solution as I don't know the best way to handle it.

On Wed, Jun 15, 2016, 03:11 Wenzel Jakob notifications@github.com wrote:

The user might press multiple buttons, so passing the state generally seems like the right way to go. What about renaming the parameter from "button" to "buttonState" or something like that?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wjakob/nanogui/issues/70#issuecomment-226131701, or mute the thread https://github.com/notifications/unsubscribe/AAG6-V5o3tq6nJ4zw44qFy5jP067tydpks5qL8HBgaJpZM4I12fU .

wjakob commented 8 years ago

That limitation (to drags with the left button) is likely to go away, see the commit in #69.

RobotCaleb commented 8 years ago

In that case, should button be the drag action originating button?

wjakob commented 8 years ago

That would be a reasonable change. Feel free to submit this as a PR.