Commit 775065d2 authored by Julien Finet's avatar Julien Finet Committed by Marcus D. Hanwell
Browse files

ENH: Mouse buttons are now binary comparable

NO_BUTTON = 0
LEFT_BUTTON = 1
MIDDLE_BUTTON = 2
RIGHT_BUTTON = 4
parent 544562ed
......@@ -36,7 +36,7 @@ vtkBlockItem::vtkBlockItem()
{
this->Label = NULL;
this->MouseOver = false;
this->MouseButtonPressed = -1;
this->MouseButtonPressed = vtkContextMouseEvent::NO_BUTTON;
this->scalarFunction = NULL;
this->Dimensions[0]=0;
this->Dimensions[1]=0;
......@@ -172,7 +172,7 @@ bool vtkBlockItem::MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
//-----------------------------------------------------------------------------
bool vtkBlockItem::MouseButtonReleaseEvent(const vtkContextMouseEvent &)
{
this->MouseButtonPressed = -1;
this->MouseButtonPressed = vtkContextMouseEvent::NO_BUTTON;
return true;
}
......
......@@ -193,7 +193,7 @@ bool vtkChartPie::MouseEnterEvent(const vtkContextMouseEvent &)
//-----------------------------------------------------------------------------
bool vtkChartPie::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
if (mouse.Button < 0)
if (mouse.Button == vtkContextMouseEvent::NO_BUTTON)
{
this->Scene->SetDirty(true);
this->Tooltip->SetVisible(this->LocatePointInPlots(mouse));
......
......@@ -1021,7 +1021,7 @@ bool vtkChartXY::MouseMoveEvent(const vtkContextMouseEvent &mouse)
// Mark the scene as dirty
this->Scene->SetDirty(true);
}
else if (mouse.Button < 0)
else if (mouse.Button == vtkContextMouseEvent::NO_BUTTON)
{
this->Scene->SetDirty(true);
this->Tooltip->SetVisible(this->LocatePointInPlots(mouse));
......
......@@ -30,9 +30,10 @@ public:
// Description:
// Enumeration of mouse buttons.
enum {
LEFT_BUTTON = 0,
MIDDLE_BUTTON,
RIGHT_BUTTON
NO_BUTTON = 0,
LEFT_BUTTON = 1,
MIDDLE_BUTTON = 2,
RIGHT_BUTTON = 4
};
// Description:
......@@ -60,7 +61,7 @@ public:
vtkVector2i LastScreenPos;
// Description:
// Mouse button that was pressed, using the anonymous enumeration.
// Mouse button that caused the event, using the anonymous enumeration.
int Button;
};
//ETX
......
......@@ -79,26 +79,26 @@ public:
this->Target->MouseMoveEvent(x, y);
break;
case vtkCommand::LeftButtonPressEvent :
this->Target->ButtonPressEvent(0, x, y);
this->Target->ButtonPressEvent(vtkContextMouseEvent::LEFT_BUTTON, x, y);
break;
case vtkCommand::MiddleButtonPressEvent :
this->Target->ButtonPressEvent(1, x, y);
this->Target->ButtonPressEvent(vtkContextMouseEvent::MIDDLE_BUTTON, x, y);
break;
case vtkCommand::RightButtonPressEvent :
this->Target->ButtonPressEvent(2, x, y);
this->Target->ButtonPressEvent(vtkContextMouseEvent::RIGHT_BUTTON, x, y);
break;
case vtkCommand::LeftButtonReleaseEvent :
this->Target->ButtonReleaseEvent(0, x, y);
this->Target->ButtonReleaseEvent(vtkContextMouseEvent::LEFT_BUTTON, x, y);
break;
case vtkCommand::MiddleButtonReleaseEvent :
this->Target->ButtonReleaseEvent(1, x, y);
this->Target->ButtonReleaseEvent(vtkContextMouseEvent::MIDDLE_BUTTON, x, y);
break;
case vtkCommand::RightButtonReleaseEvent :
this->Target->ButtonReleaseEvent(2, x, y);
this->Target->ButtonReleaseEvent(vtkContextMouseEvent::RIGHT_BUTTON, x, y);
break;
case vtkCommand::MouseWheelForwardEvent :
// There is a forward and a backward event - not clear on deltas...
this->Target->MouseWheelEvent(1, x, y);
this->Target->MouseWheelEvent(+1, x, y);
break;
case vtkCommand::MouseWheelBackwardEvent :
// There is a forward and a backward event - not clear on deltas...
......@@ -126,8 +126,8 @@ class vtkContextScene::Private
public:
Private()
{
this->itemMousePressCurrent = -1;
this->Event.Button = -1;
this->itemMousePressCurrent = -1;
this->Event.Button = vtkContextMouseEvent::NO_BUTTON;
this->IsDirty = true;
}
~Private()
......@@ -615,7 +615,7 @@ void vtkContextScene::ButtonReleaseEvent(int button, int x, int y)
->MouseButtonReleaseEvent(event);
this->Storage->itemMousePressCurrent = -1;
}
this->Storage->Event.Button = -1;
this->Storage->Event.Button = vtkContextMouseEvent::NO_BUTTON;
}
void vtkContextScene::MouseWheelEvent(int delta, int x, int y)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment