Clicking with keyboard handles keyboard modifiers (GAL).

This commit is contained in:
Maciej Suminski 2015-07-07 18:36:52 +02:00
parent e7099036d7
commit 15e9e69ae0
1 changed files with 58 additions and 59 deletions

View File

@ -438,7 +438,6 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
VECTOR2D cursor = getViewControls()->GetCursorPosition();
VECTOR2I gridSize = gridHelper.GetGrid();
VECTOR2D newCursor = gridHelper.Align( cursor );
bool warp = true;
if( fastMove )
gridSize = gridSize * 10;
@ -461,29 +460,34 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
newCursor += VECTOR2D( gridSize.x, 0 );
break;
case COMMON_ACTIONS::CURSOR_CLICK:
{
TOOL_EVENT evtClick( TC_MOUSE, TA_MOUSE_CLICK, BUT_LEFT );
evtClick.SetMousePosition( getViewControls()->GetCursorPosition() );
m_toolMgr->ProcessEvent( evtClick );
warp = false;
}
break;
case COMMON_ACTIONS::CURSOR_CLICK: // fall through
case COMMON_ACTIONS::CURSOR_DBL_CLICK:
{
TOOL_EVENT evtDblClick( TC_MOUSE, TA_MOUSE_DBLCLICK, BUT_LEFT );
evtDblClick.SetMousePosition( getViewControls()->GetCursorPosition() );
m_toolMgr->ProcessEvent( evtDblClick );
warp = false;
TOOL_ACTIONS action;
int modifiers = 0;
modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
if( type == COMMON_ACTIONS::CURSOR_CLICK )
action = TA_MOUSE_CLICK;
else if( type == COMMON_ACTIONS::CURSOR_DBL_CLICK )
action = TA_MOUSE_DBLCLICK;
else
assert( false );
TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
evt.SetMousePosition( getViewControls()->GetCursorPosition() );
m_toolMgr->ProcessEvent( evt );
return 0;
}
break;
}
if( warp )
{
// Handler cursor movement
KIGFX::VIEW* view = getView();
VECTOR2D worldCursor = newCursor;
newCursor = view->ToScreen( newCursor );
// Pan the screen if required
@ -503,7 +507,7 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
{
delta.x = newCursor.x - screenBox.GetRight();
// -1 is to keep the cursor within the drawing area,
// so the cursor coordinates are updated
// so the cursor coordinates are still updated
newCursor.x = screenBox.GetRight() - 1;
}
@ -516,19 +520,14 @@ int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
{
delta.y = newCursor.y - screenBox.GetBottom();
// -1 is to keep the cursor within the drawing area,
// so the cursor coordinates are updated
// so the cursor coordinates are still updated
newCursor.y = screenBox.GetBottom() - 1;
}
view->SetCenter( view->GetCenter() + view->ToWorld( delta, false ) );
}
TOOL_EVENT evt( TC_MOUSE, TA_MOUSE_MOTION );
evt.SetMousePosition( worldCursor );
m_toolMgr->ProcessEvent( evt );
m_frame->GetGalCanvas()->WarpPointer( newCursor.x, newCursor.y );
}
return 0;
}