Commit a525c890 authored by Maciej Suminski's avatar Maciej Suminski

Alternative way to handle mouse buttons (GAL).

parent 0adb6fa9
...@@ -85,6 +85,30 @@ struct TOOL_DISPATCHER::BUTTON_STATE ...@@ -85,6 +85,30 @@ struct TOOL_DISPATCHER::BUTTON_STATE
dragging = false; dragging = false;
pressed = false; pressed = false;
} }
///> Checks the current state of the button.
bool GetState() const
{
wxMouseState mouseState = wxGetMouseState();
switch( button )
{
case BUT_LEFT:
return mouseState.LeftIsDown();
case BUT_MIDDLE:
return mouseState.MiddleIsDown();
case BUT_RIGHT:
return mouseState.RightIsDown();
default:
assert( false );
break;
}
return false;
}
}; };
...@@ -129,9 +153,21 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -129,9 +153,21 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
boost::optional<TOOL_EVENT> evt; boost::optional<TOOL_EVENT> evt;
bool isClick = false; bool isClick = false;
bool up = type == st->upEvent; // bool up = type == st->upEvent;
bool down = type == st->downEvent; // bool down = type == st->downEvent;
bool up = false, down = false;
bool dblClick = type == st->dblClickEvent; bool dblClick = type == st->dblClickEvent;
bool state = st->GetState();
if( !dblClick )
{
// Sometimes the dispatcher does not receive mouse button up event, so it stays
// in the dragging mode even if the mouse button is not held anymore
if( st->pressed && !state )
up = true;
else if( !st->pressed && state )
down = true;
}
int mods = decodeModifiers<wxMouseEvent>( static_cast<wxMouseEvent*>( &aEvent ) ); int mods = decodeModifiers<wxMouseEvent>( static_cast<wxMouseEvent*>( &aEvent ) );
int args = st->button | mods; int args = st->button | mods;
......
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