diff --git a/docs/changes.txt b/docs/changes.txt index a3d2550fb1..d89b055450 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -167,6 +167,7 @@ wxOSX: and OSXDisableAllSmartSubstitutions() to control wxTextCtrl smart behavior. - Don't allow interacting with disabled wxSlider (Andreas Falkenhahn). - Fix setting alignment in wxTextCtrl with wxTE_DONTWRAP (Andreas Falkenhahn). +- Allow pasting using Cmd+V in wxTextCtrl with wxTE_PASSWORD style. Unix: diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 8180421885..50cca3f039 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -258,6 +258,25 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; } } } + else if ( commandSelector == @selector(noop:) ) + { + // We are called with this strange "noop:" selector when an + // attempt to paste the text into a password text control using + // Cmd+V is made. Check if we're really in this case and, if + // we're, do paste as otherwise nothing happens by default + // which is annoying, it is pretty common and useful to paste + // passwords, e.g. from a password manager. + NSEvent* cevent = [[NSApplication sharedApplication] currentEvent]; + if ( [cevent type] == NSKeyDown && + [cevent keyCode] == 9 /* V */ && + ([cevent modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask ) + { + wxTextWidgetImpl* impl = (wxNSTextFieldControl * ) wxWidgetImpl::FindFromWXWidget( self ); + wxTextEntry * const entry = impl->GetTextEntry(); + entry->Paste(); + handled = YES; + } + } } }