Handle wxTE_PROCESS_ENTER with wxTE_PASSWORD correctly in wxOSX.

Controls with wxTE_PASSWORD style didn't send wxEVT_TEXT_ENTER even if they
also had wxTE_PROCESS_ENTER. Fix this by checking for the latter style before
mapping the enter presses to default button activation.

See #14930.
This commit is contained in:
mj_smoker
2015-07-18 01:45:12 +02:00
committed by Vadim Zeitlin
parent c269398588
commit 8e0799e3e5

View File

@@ -213,17 +213,29 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
{ {
if (commandSelector == @selector(insertNewline:)) if (commandSelector == @selector(insertNewline:))
{ {
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(wxpeer), wxTopLevelWindow); if ( wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER )
if ( tlw && tlw->GetDefaultItem() )
{ {
wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); wxCommandEvent event(wxEVT_TEXT_ENTER, wxpeer->GetId());
if ( def && def->IsEnabled() ) event.SetEventObject( wxpeer );
wxTextWidgetImpl* impl = (wxNSTextFieldControl * ) wxWidgetImpl::FindFromWXWidget( self );
wxTextEntry * const entry = impl->GetTextEntry();
event.SetString( entry->GetValue() );
handled = wxpeer->HandleWindowEvent( event );
}
else
{
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(wxpeer), wxTopLevelWindow);
if ( tlw && tlw->GetDefaultItem() )
{ {
wxCommandEvent event(wxEVT_BUTTON, def->GetId() ); wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
event.SetEventObject(def); if ( def && def->IsEnabled() )
def->Command(event); {
handled = YES; wxCommandEvent event(wxEVT_BUTTON, def->GetId() );
} event.SetEventObject(def);
def->Command(event);
handled = YES;
}
}
} }
} }
} }