Exemplo n.º 1
0
void AudacityApp::OnKey(wxKeyEvent& event)
{
    AudacityProject *audacityPrj = GetActiveProject();
    wxString newStr = "";

    long key = event.GetKeyCode();

    if(event.ControlDown())
        newStr += "Ctrl+";

    if(event.AltDown())
        newStr += "Alt+";

    if(event.ShiftDown())
        newStr += "Shift+";

    if (event.ControlDown() && key >= 1 && key <= 26)
        newStr += (char)(64 + key);
    else if (key >= 33 && key <= 126)
        newStr += (char)key;
    else if (key == WXK_BACK)
        newStr = "Backspace";
    else if (key == WXK_DELETE)
        newStr = "Delete";
    else if (key == WXK_SPACE)
        newStr = "Spacebar";
    else
    {
        event.Skip();
        return; // Don't change it if we don't recognize the key
    }

    if(audacityPrj->IsActive())
    {
        int commandIndex = audacityPrj->FindCommandByCombos(newStr);

        if(audacityPrj->GetCommandState(commandIndex) == enabledMenu)
        {
            audEventFunction audFunc = audacityPrj->GetCommandFunc(commandIndex);

            if(audFunc)
                (audacityPrj->*((wxEventFunction) audFunc))(event);

            return;
        }
    }

    event.Skip();
}
Exemplo n.º 2
0
int AudacityApp::OnAllKeys(wxKeyEvent& event)
{
   AudacityProject *audacityPrj = GetActiveProject();

   if (!audacityPrj) {
      return -1;
   }

   if(audacityPrj->IsActive())
   {
      if (event.GetEventType() == wxEVT_KEY_DOWN) {
         if (audacityPrj->HandleKeyDown(event))
            return true;
      }
      if (event.GetEventType() == wxEVT_KEY_UP) {
         if (audacityPrj->HandleKeyUp(event))
            return true;
      }
   }

   return -1;
}