#include "wx/osx/cocoa/private/textimpl.h"
@interface wxNSSecureTextField : NSSecureTextField
-
+{
+}
@end
@implementation wxNSSecureTextField
}
}
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+
@end
@interface wxNSTextView : NSScrollView
+{
+}
@end
}
}
+- (void)textDidChange:(NSNotification *)aNotification
+{
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+
+- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)commandSelector
+{
+ wxUnusedVar(aTextView);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if (commandSelector == @selector(insertNewline:))
+ {
+ if ( wxpeer && wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+ }
+
+ return NO;
+}
@end
@implementation wxNSTextField
}
}
-/*
+- (void) setEnabled:(BOOL) flag
+{
+ [super setEnabled: flag];
+
+ if (![self drawsBackground]) {
+ // Static text is drawn incorrectly when disabled.
+ // For an explanation, see
+ // http://www.cocoabuilder.com/archive/message/cocoa/2006/7/21/168028
+ if (flag) {
+ [self setTextColor: [NSColor controlTextColor]];
+ } else {
+ [self setTextColor: [NSColor secondarySelectedControlColor]];
+ }
+ }
+}
+
- (void)controlTextDidChange:(NSNotification *)aNotification
{
+ wxUnusedVar(aNotification);
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if ( impl )
{
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
}
}
+typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl *control, NSTextView* textView, SEL commandSelector);
+
+- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector
+{
+ wxUnusedVar(textView);
+ wxUnusedVar(control);
+ if (commandSelector == @selector(insertNewline:))
+ {
+ wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+ 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<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+ }
+
+ return NO;
+}
+/*
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
if ( impl )
void wxNSTextViewControl::SetSelection( long from , long to )
{
- [m_textView setSelectedRange:NSMakeRange(from, to-from)];
+ NSRange selrange = NSMakeRange(from, to-from);
+ [m_textView setSelectedRange:selrange];
+ [m_textView scrollRangeToVisible:selrange];
}
void wxNSTextViewControl::WriteText(const wxString& str)
// temp hack to get logging working early
wxString former = GetStringValue();
SetStringValue( former + str );
+ SetSelection(GetStringValue().length(), GetStringValue().length());
}
// wxNSTextFieldControl
// temp hack to get logging working early
wxString former = GetStringValue();
SetStringValue( former + str );
+ SetSelection(GetStringValue().length(), GetStringValue().length());
}
-void wxNSTextFieldControl::controlAction(WXWidget slf, void* _cmd, void *sender)
+void wxNSTextFieldControl::controlAction(WXWidget WXUNUSED(slf),
+ void* WXUNUSED(_cmd), void *WXUNUSED(sender))
{
wxWindow* wxpeer = (wxWindow*) GetWXPeer();
if ( wxpeer && (wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER) )
//
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
- wxWindowMac* parent,
- wxWindowID id,
+ wxWindowMac* WXUNUSED(parent),
+ wxWindowID WXUNUSED(id),
const wxString& str,
const wxPoint& pos,
const wxSize& size,
long style,
- long extraStyle)
+ long WXUNUSED(extraStyle))
{
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
- NSTextField* v = nil;
wxWidgetCocoaImpl* c = NULL;
if ( style & wxTE_MULTILINE || style & wxTE_RICH || style & wxTE_RICH2 )
{
+ wxNSTextView* v = nil;
v = [[wxNSTextView alloc] initWithFrame:r];
c = new wxNSTextViewControl( wxpeer, v );
static_cast<wxNSTextViewControl*>(c)->SetStringValue(str);
}
else
{
+ NSTextField* v = nil;
if ( style & wxTE_PASSWORD )
v = [[wxNSSecureTextField alloc] initWithFrame:r];
else