Rework this a bit to handle ctrl+clicking and ctrl+alt+clicking for right and middle mouse button.

Fixes ticket #3061.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28528 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2008-11-06 03:07:38 +00:00
parent 83b6ce6be6
commit 01406f374d
2 changed files with 26 additions and 15 deletions

View File

@ -100,6 +100,7 @@ MouseView::MouseView(BRect rect, const MouseSettings &settings)
//fMouseDownBitmap = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "pressed_mouse_bmap");
fMouseDownBounds = fMouseDownBitmap->Bounds();
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
}
@ -119,10 +120,34 @@ MouseView::GetPreferredSize(float *_width, float *_height)
*_height = fMouseBitmap != NULL ? fMouseBitmap->Bounds().Height() : 82;
}
void
MouseView::MouseUp(BPoint)
{
fButtons = 0;
Invalidate(BRect(0, kButtonTop, fMouseDownBounds.Width(),
kButtonTop + fMouseDownBounds.Height()));
fOldButtons = fButtons;
}
void
MouseView::MouseDown(BPoint where)
{
BMessage *mouseMsg = Window()->CurrentMessage();
fButtons = mouseMsg->FindInt32("buttons");
int32 modifiers = mouseMsg->FindInt32("modifiers");
if (modifiers & B_CONTROL_KEY) {
if (modifiers & B_COMMAND_KEY)
fButtons = B_TERTIARY_MOUSE_BUTTON;
else
fButtons = B_SECONDARY_MOUSE_BUTTON;
}
if (fOldButtons != fButtons) {
Invalidate(BRect(0, kButtonTop,
fMouseDownBounds.Width(), kButtonTop + fMouseDownBounds.Height()));
fOldButtons = fButtons;
}
const int32 *offset = getButtonOffsets(fType);
int32 button = -1;
for (int32 i = 0; i <= fType; i++) {
@ -168,20 +193,6 @@ MouseView::AttachedToWindow()
}
void
MouseView::Pulse()
{
BPoint point;
GetMouse(&point, &fButtons, true);
if (fOldButtons != fButtons) {
Invalidate(BRect(0, kButtonTop,
fMouseDownBounds.Width(), kButtonTop + fMouseDownBounds.Height()));
fOldButtons = fButtons;
}
}
void
MouseView::Draw(BRect updateFrame)
{

View File

@ -32,8 +32,8 @@ class MouseView : public BView {
virtual void AttachedToWindow();
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void Draw(BRect frame);
virtual void Pulse();
virtual void GetPreferredSize(float *_width, float *_height);
void SetMouseType(int32 type);