Commit ec9cd765 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Fix default menu alt key accelerator bug. (fixes lp:1035151)

* Add hot key handled return indicator to DRAW_FRAME::GeneralControl() and
  DRAW_FRAME::OnHotKey() and all classed derived from DRAW_FRAME.
* Add code to all GeneralControl() and OnHotKey() functions to return true if
  hot key was handled.
* Call event skip in DRAW_PANEL::OnKeyEvent() when key event is not handled to
  allow default menu event handler to function properly.
parent 020a0ae4
Loading
Loading
Loading
Loading
+5 −11
Original line number Original line Diff line number Diff line
@@ -219,24 +219,17 @@ void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
    event.Skip();
    event.Skip();
}
}


/* function SkipNextLeftButtonReleaseEvent

 * after calling this function, if the left mouse button
 * is down, the next left mouse button release event will be ignored.
 * It is is usefull for instance when closing a dialog on a mouse click,
 * to skip the next mouse left button release event
 * by the parent window, because the mouse button
 * clicked on the dialog is often released in the parent frame,
 * and therefore creates a left button released mouse event
 * which can be unwanted in some cases
 */
void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
{
{
   m_canvas->SetIgnoreLeftButtonReleaseEvent( true );
   m_canvas->SetIgnoreLeftButtonReleaseEvent( true );
}
}



void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
{
    SetGridVisibility( !IsGridVisible() );
    SetGridVisibility( !IsGridVisible() );

    if( IsGalCanvasActive() )
    if( IsGalCanvasActive() )
    {
    {
        GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
        GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
@@ -322,8 +315,9 @@ void EDA_DRAW_FRAME::ReCreateMenuBar()
}
}




void EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
{
{
    return false;
}
}




+3 −1
Original line number Original line Diff line number Diff line
@@ -1389,7 +1389,9 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
    pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );
    pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );


    GetParent()->SetMousePosition( pos );
    GetParent()->SetMousePosition( pos );
    GetParent()->GeneralControl( &DC, pos, localkey );

    if( !GetParent()->GeneralControl( &DC, pos, localkey ) )
        event.Skip();
}
}




+9 −2
Original line number Original line Diff line number Diff line
@@ -327,13 +327,15 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
}
}




void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
    {
        m_movingCursorWithKeyboard = false;
        m_movingCursorWithKeyboard = false;
        return;
        return false;
    }
    }


    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
@@ -373,12 +375,17 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi
    case ' ':
    case ' ':
        GetScreen()->m_O_Curseur = GetCrossHairPosition();
        GetScreen()->m_O_Curseur = GetCrossHairPosition();
        break;
        break;

    default:
        eventHandled = false;
    }
    }


    SetCrossHairPosition( pos );
    SetCrossHairPosition( pos );
    RefreshCrossHair( oldpos, aPosition, aDC );
    RefreshCrossHair( oldpos, aPosition, aDC );


    UpdateStatusBar();    /* Display new cursor coordinates */
    UpdateStatusBar();    /* Display new cursor coordinates */

    return eventHandled;
}
}




+1 −1
Original line number Original line Diff line number Diff line
@@ -92,7 +92,7 @@ public:
    void    OnLeftClick( wxDC* DC, const wxPoint& MousePos );
    void    OnLeftClick( wxDC* DC, const wxPoint& MousePos );
    void    OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
    void    OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
    bool    OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
    bool    OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
    void    GeneralControl( wxDC* DC, const wxPoint& aPosition, int aHotKey = 0 );
    bool    GeneralControl( wxDC* DC, const wxPoint& aPosition, int aHotKey = 0 );
    void    InstallOptionsDisplay( wxCommandEvent& event );
    void    InstallOptionsDisplay( wxCommandEvent& event );
    MODULE* Get_Module( const wxString& CmpName );
    MODULE* Get_Module( const wxString& CmpName );


+26 −12
Original line number Original line Diff line number Diff line
@@ -203,19 +203,22 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF
}
}




void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
    {
        m_movingCursorWithKeyboard = false;
        m_movingCursorWithKeyboard = false;
        return;
        return false;
    }
    }


    // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
    // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
    // for next cursor position
    // for next cursor position
    // ( shift or ctrl key down are PAN command with mouse wheel)
    // ( shift or ctrl key down are PAN command with mouse wheel)
    bool snapToGrid = true;
    bool snapToGrid = true;

    if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
    if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
        snapToGrid = false;
        snapToGrid = false;


@@ -236,28 +239,33 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
        SCH_SCREEN* screen = GetScreen();
        SCH_SCREEN* screen = GetScreen();


        if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
        if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
            OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
        else
        else
            OnHotKey( aDC, aHotKey, aPosition, NULL );
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
    }
    }


    UpdateStatusBar();    /* Display cursor coordinates info */
    UpdateStatusBar();    /* Display cursor coordinates info */

    return eventHandled;
}
}




void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
    {
        m_movingCursorWithKeyboard = false;
        m_movingCursorWithKeyboard = false;
        return;
        return false;
    }
    }


    // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
    // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
    // for next cursor position
    // for next cursor position
    // ( shift or ctrl key down are PAN command with mouse wheel)
    // ( shift or ctrl key down are PAN command with mouse wheel)
    bool snapToGrid = true;
    bool snapToGrid = true;

    if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
    if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
        snapToGrid = false;
        snapToGrid = false;


@@ -275,20 +283,24 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH


    if( aHotKey )
    if( aHotKey )
    {
    {
        OnHotKey( aDC, aHotKey, aPosition, NULL );
        eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
    }
    }


    UpdateStatusBar();
    UpdateStatusBar();

    return eventHandled;
}
}




void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
    {
        m_movingCursorWithKeyboard = false;
        m_movingCursorWithKeyboard = false;
        return;
        return false;
    }
    }


    wxPoint pos = aPosition;
    wxPoint pos = aPosition;
@@ -304,10 +316,12 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
        SCH_SCREEN* screen = GetScreen();
        SCH_SCREEN* screen = GetScreen();


        if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
        if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
            OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
        else
        else
            OnHotKey( aDC, aHotKey, aPosition, NULL );
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
    }
    }


    UpdateStatusBar();    /* Display cursor coordinates info */
    UpdateStatusBar();    // Display cursor coordinates info.

    return eventHandled;
}
}
Loading