virtual bool EmulateKeyPress(const wxKeyEvent& event);
- // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does and
- // return true if the event was processed
- static bool SendTextUpdatedEvent(wxWindow *win);
- bool SendTextUpdatedEvent() { return SendTextUpdatedEvent(this); }
-
// do the window-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
wxPoint GetMargins() const
{ return DoGetMargins(); }
+
+ // events
+ // ------
+
+ // generate the wxEVT_COMMAND_TEXT_UPDATED event for GetEditableWindow(),
+ // like SetValue() does and return true if the event was processed
+ //
+ // NB: this is public for wxRichTextCtrl use only right now, do not call it
+ static bool SendTextUpdatedEvent(wxWindow *win);
+
protected:
// flags for DoSetValue(): common part of SetValue() and ChangeValue() and
// also used to implement WriteText() in wxMSW
friend class EventsSuppressor;
- // return true if the events are currently not suppressed
- bool EventsAllowed() const { return m_eventsBlock == 0; }
+ // generate the wxEVT_COMMAND_TEXT_UPDATED event for this window
+ bool SendTextUpdatedEvent()
+ {
+ return SendTextUpdatedEvent(GetEditableWindow());
+ }
+
+ // generate the wxEVT_COMMAND_TEXT_UPDATED event for this window if the
+ // events are not currently disabled
+ void SendTextUpdatedEventIfAllowed()
+ {
+ if ( EventsAllowed() )
+ SendTextUpdatedEvent();
+ }
private:
// suppress or resume the text changed events generation: don't use these
// initially the generation of the events is enabled
virtual void EnableTextChangedEvents(bool WXUNUSED(enable)) { }
+ // return true if the events are currently not suppressed
+ bool EventsAllowed() const { return m_eventsBlock == 0; }
+
+
// if this counter is non-null, events are blocked
unsigned m_eventsBlock;
void wxTextCtrl::CocoaTarget_action(void)
{
- // NSTextField only sends the action message on enter key press and thus
- // we send the appropriate event type.
- wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, GetId());
-
- // See wxTextCtrlBase::SendTextUpdatedEvent for why we don't set the string.
- //event.SetString(GetValue());
-
- event.SetEventObject(this);
- HandleWindowEvent(event);
+ SendTextUpdatedEvent();
}
void wxTextCtrl::AppendText(wxString const&)
return wxTE_HT_UNKNOWN;
}
-// ----------------------------------------------------------------------------
-// events
-// ----------------------------------------------------------------------------
-
-/* static */
-bool wxTextCtrlBase::SendTextUpdatedEvent(wxWindow *win)
-{
- wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, 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->GetEventHandler()->ProcessEvent(event);
-}
-
#else // !wxUSE_TEXTCTRL
// define this one even if !wxUSE_TEXTCTRL because it is also used by other
return wxPoint(-1, -1);
}
+// ----------------------------------------------------------------------------
+// events
+// ----------------------------------------------------------------------------
+
+/* static */
+bool wxTextEntryBase::SendTextUpdatedEvent(wxWindow *win)
+{
+ wxCHECK_MSG( win, false, "can't send an event without a window" );
+
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, 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);
+}
+
#endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX
// now call it to do the rest (not related to refreshing)
ClearSelection();
- if ( EventsAllowed() )
- SendTextUpdatedEvent();
+ SendTextUpdatedEventIfAllowed();
}
void wxTextCtrl::Remove(wxTextPos from, wxTextPos to)