virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
+ virtual bool SendMaxLenEvent();
+
// Implementation
// --------------
@interface wxMaximumLengthFormatter : NSFormatter
{
int maxLength;
+ wxTextEntry* field;
}
@end
int len = [*partialStringPtr length];
if ( maxLength > 0 && len > maxLength )
{
- // TODO wxEVT_TEXT_MAXLEN
+ field->SendMaxLenEvent();
return NO;
}
return YES;
}
+- (void) setTextEntry:(wxTextEntry*) tf
+{
+ field = tf;
+}
+
@end
@implementation wxNSSecureTextField
{
wxMaximumLengthFormatter* formatter = [[[wxMaximumLengthFormatter alloc] init] autorelease];
[formatter setMaxLength:len];
+ [formatter setTextEntry:GetTextEntry()];
[m_textField setFormatter:formatter];
}
return m_editable ;
}
+bool wxTextEntry::SendMaxLenEvent()
+{
+ wxWindow *win = GetEditableWindow();
+ wxCHECK_MSG( win, false, "can't send an event without a window" );
+
+ wxCommandEvent event(wxEVT_TEXT_MAXLEN, win->GetId());
+
+ // do not do this as it could be very inefficient if the text control
+ // contains a lot of text and we're not using ref-counted wxString
+ // implementation -- instead, event.GetString() will query the control for
+ // its current text if needed
+ //event.SetString(win->GetValue());
+
+ event.SetEventObject(win);
+ return win->HandleWindowEvent(event);
+}
+
// ----------------------------------------------------------------------------
// Undo/redo
// ----------------------------------------------------------------------------