X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e181c7a2c32193fc8138cc32ed07984eadd4a21..9b66a1d31a32e9235792261db6ff755ce26ab5c1:/src/osx/cocoa/textctrl.mm diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 7b7189e7d8..3e5b8d87e7 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -51,19 +51,16 @@ @implementation wxNSTextField -- (void)setImplementation: (wxWidgetImpl *) theImplementation -{ - impl = theImplementation; -} - -- (wxWidgetImpl*) implementation -{ - return impl; -} +WXCOCOAIMPL_COMMON_IMPLEMENTATION -- (BOOL) isFlipped +- (id)initWithFrame:(NSRect)frame { - return YES; + [super initWithFrame:frame]; + impl = NULL; + [self setDelegate: self]; + [self setTarget: self]; +// [self setAction: @selector(enterAction:)]; + return self; } // use our common calls @@ -71,7 +68,49 @@ { [self setStringValue: title]; } - +/* +- (void)controlTextDidChange:(NSNotification *)aNotification +{ + 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 ); + } + } +} + +- (void)controlTextDidEndEditing:(NSNotification *)aNotification +{ + 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 @@ -136,11 +176,14 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, long style, long extraStyle) { - NSView* sv = (wxpeer->GetParent()->GetHandle() ); - NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r]; - [sv addSubview:v]; + + if ( style & wxNO_BORDER ) + { + [v setBezeled:NO]; + [v setBordered:NO]; + } //[v setBezeled:NO]; //[v setEditable:NO];