[haiku-development] Re: Obtaining mouse button type
- From: "Ryan Leavengood" <leavengood@xxxxxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Mon, 9 Jun 2008 00:51:21 -0400
On Mon, Jun 9, 2008 at 12:35 AM, James Kim <jkim202@xxxxxxxxxxxxxxxxx> wrote:
> Hi! I have come across another problem with mouse event handling. I need
> to find out what button (left, right or none) is being pressed while
> BView::MouseMoved(). I have looked at GetMouse() but I cannot figure out
> how to retrieve the button information from it because GetMouse()
> returns nothing. Any suggestions or a reference to an example would be
> very appreciated. Thank you.
GetMouse() has a second parameter which is a pointer to a uint32 that
you can use to see which buttons are pressed. Something like this
(untested!)
BPoint cursor;
uint32 buttons = 0;
GetMouse(&cursor, &buttons);
if (buttons & B_PRIMARY_MOUSE_BUTTON)
// First mouse button
DoSomething();
if (buttons & B_SECONDARY_MOUSE_BUTTON)
// Second mouse button
DoSomethingElse();
if (buttons & B_TERTIARY_MOUSE_BUTTON)
// Third mouse button
DoSomethingElse2();
Note that in theory more than one button could be pressed at one time,
though usually probably not. Note in the above I don't use else if,
though you might want to.
Ryan
- References:
- [haiku-development] Obtaining mouse button type
- From: James Kim
Other related posts:
- » [haiku-development] Obtaining mouse button type
- » [haiku-development] Re: Obtaining mouse button type
- » [haiku-development] Re: Obtaining mouse button type
- [haiku-development] Obtaining mouse button type
- From: James Kim