How do i figure out whick mouse button was MouseUp()ed

Forum thread started by nobbe on Thu, 2006-03-16 13:02

Hey,

My MouseDown function below works as intended. It prints which button
that was clicked.
However the MouseUp function does not work.
It contains a "buttons" field, but it doesn't printf anything.

Anyone know what's wrong?

void View::MouseDown(BPoint point) {
   	int32 buttons;
   	if (Window()->CurrentMessage()->FindInt32("buttons", (int32 *)&buttons) == B_NO_ERROR) {
		if (buttons & B_PRIMARY_MOUSE_BUTTON) {
			printf("down pri");
		}
		if (buttons & B_SECONDARY_MOUSE_BUTTON) {
			printf("down sec");
		}
		if (buttons & B_TERTIARY_MOUSE_BUTTON) {
			printf("down ter");
		}
   	}
}

void View::MouseUp(BPoint point) {
	uint32 buttons;
  	if (Window()->CurrentMessage()->FindInt32("buttons", (int32 *)&buttons) == B_NO_ERROR) {
		if (buttons & B_PRIMARY_MOUSE_BUTTON) {
			printf("up pri");
		}
		if (buttons & B_SECONDARY_MOUSE_BUTTON) {
			printf("up sec");
		}
		if (buttons & B_TERTIARY_MOUSE_BUTTON) {
			printf("up ter");
		}
   	}
}

[/code]

Comments

How do i figure out whick mouse button was MouseUp()ed

this is a good question it cost me some hours until I look in the bebook and see that there is no button field in the mouse up message!

Is there a other way to get the mouse up button? What is the reason that there is no button field in the message?

How do i figure out whick mouse button was MouseUp()ed

Could GetMouse() help?

Re: How do i figure out whick mouse button was MouseUp()ed

nobbe wrote:
Hey,

My MouseDown function below works as intended. It prints which button
that was clicked.
However the MouseUp function does not work.
It contains a "buttons" field, but it doesn't printf anything.

Does the MouseUp() function get called at all? My Be Developer's Guide (printed, O'Reilly) says "This function is a placeholder for future releases; it isn't currently called. Although B_MOUSE_UP messages are generated, a virtual function is not now called to handle them."

Granted it's been a long time since I did some programming on BeOS, and the book was released around R4 or earlier...

How do i figure out whick mouse button was MouseUp()ed

Ok, here's what i've figured out so far:

There IS both a B_MOUSE_UP message in R5 and a MouseUp() hook in BView(that gets called).
There IS also a buttons field in the B_MOUSE_UP message, however this is
undocumented and &buttons is always 0.

I suppose this was not finished in R5.

I'm going to test with GetMouse() in MouseUp() as [Beta] said above.