X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4825ef73a5f190b8f39c59df098c3f39fa4464b..9b66a1d31a32e9235792261db6ff755ce26ab5c1:/src/osx/cocoa/textctrl.mm diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 6a2b2946de..3e5b8d87e7 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -51,27 +51,66 @@ @implementation wxNSTextField -- (void)setImplementation: (wxWidgetImpl *) theImplementation +WXCOCOAIMPL_COMMON_IMPLEMENTATION + +- (id)initWithFrame:(NSRect)frame { - impl = theImplementation; + [super initWithFrame:frame]; + impl = NULL; + [self setDelegate: self]; + [self setTarget: self]; +// [self setAction: @selector(enterAction:)]; + return self; } -- (wxWidgetImpl*) implementation +// use our common calls +- (void) setTitle:(NSString *) title { - return impl; + [self setStringValue: title]; } - -- (BOOL) isFlipped +/* +- (void)controlTextDidChange:(NSNotification *)aNotification { - return YES; + if ( impl ) + { + wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + if ( wxpeer ) { + wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId()); + event.SetEventObject( wxpeer ); + event.SetString( static_cast(wxpeer)->GetValue() ); + wxpeer->HandleWindowEvent( event ); + } + } } -// use our common calls -- (void) setTitle:(NSString *) title +- (void)controlTextDidEndEditing:(NSNotification *)aNotification { - [self setStringValue: title]; + if ( impl ) + { + wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + if ( wxpeer ) { + wxFocusEvent event(wxEVT_KILL_FOCUS, wxpeer->GetId()); + event.SetEventObject( wxpeer ); + event.SetWindow( wxpeer ); + wxpeer->HandleWindowEvent( event ); + } + } } +- (void) enterAction: (id) sender +{ + if ( impl ) + { + wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + if ( wxpeer && (wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER) ) { + wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId()); + event.SetEventObject( wxpeer ); + event.SetString( static_cast(wxpeer)->GetValue() ); + wxpeer->HandleWindowEvent( event ); + } + } +} +*/ @end wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) @@ -110,6 +149,7 @@ bool wxNSTextFieldControl::CanPaste() const void wxNSTextFieldControl::SetEditable(bool editable) { + [(wxNSTextField*) m_osxView setEditable:editable]; } void wxNSTextFieldControl::GetSelection( long* from, long* to) const