diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2018-04-29 17:33:33 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2018-04-29 17:52:43 +0200 |
commit | e39f5fa5d6b1b09df16271cabb1dda5d42c0b980 (patch) | |
tree | cb3aff4a8c04c6b39c014a37e0683fd5b7817d94 /src/Main/GraphicUserInterface.cpp | |
parent | 7a842266b3f2e69d1706aec3039b661e3a5b25dd (diff) | |
download | VeraCrypt-e39f5fa5d6b1b09df16271cabb1dda5d42c0b980.tar.gz VeraCrypt-e39f5fa5d6b1b09df16271cabb1dda5d42c0b980.zip |
MacOSX: support pasting values to password fields using keyboard (CMD+V and CMD+A now working properly). This make using password managers with VeraCrypt easier.
Diffstat (limited to 'src/Main/GraphicUserInterface.cpp')
-rwxr-xr-x | src/Main/GraphicUserInterface.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp index 9ae735e4..ba283af4 100755 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -37,6 +37,11 @@ namespace VeraCrypt { +#ifdef TC_MACOSX + int GraphicUserInterface::g_customIdCmdV = 0; + int GraphicUserInterface::g_customIdCmdA = 0; +#endif + GraphicUserInterface::GraphicUserInterface () : ActiveFrame (nullptr), BackgroundMode (false), @@ -51,6 +56,8 @@ namespace VeraCrypt #endif #ifdef TC_MACOSX + g_customIdCmdV = wxNewId(); + g_customIdCmdA = wxNewId(); wxApp::s_macHelpMenuTitleName = _("&Help"); #endif } @@ -657,6 +664,41 @@ namespace VeraCrypt { SetBackgroundMode (false); } + + bool GraphicUserInterface::HandlePasswordEntryCustomEvent (wxEvent& event) + { + bool bHandled = false; + if ( (event.GetEventType() == wxEVT_MENU) + && ((event.GetId() == g_customIdCmdV) || (event.GetId() == g_customIdCmdA))) + { + wxWindow* focusedCtrl = wxWindow::FindFocus(); + if (focusedCtrl + && (focusedCtrl->IsKindOf(wxCLASSINFO(wxTextCtrl))) + && (focusedCtrl->GetWindowStyle() & wxTE_PASSWORD)) + { + wxTextCtrl* passwordCtrl = (wxTextCtrl*) focusedCtrl; + if (event.GetId() == g_customIdCmdV) + passwordCtrl->Paste (); + else if (event.GetId() == g_customIdCmdA) + passwordCtrl->SelectAll (); + bHandled = true; + } + } + + return bHandled; + } + + void GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window) + { + // we manually handle CMD+V and CMD+A on password fields in order to support + // pasting password values into them. By default, wxWidgets doesn't handle this + // for password entry fields. + wxAcceleratorEntry entries[2]; + entries[0].Set(wxACCEL_CMD, (int) 'V', g_customIdCmdV); + entries[1].Set(wxACCEL_CMD, (int) 'A', g_customIdCmdA); + wxAcceleratorTable accel(sizeof(entries) / sizeof(wxAcceleratorEntry), entries); + window->SetAcceleratorTable(accel); + } #endif void GraphicUserInterface::MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const |