virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
+ // Caret handling (Windows only)
+
+ bool ShowNativeCaret(bool show = true);
+ bool HideNativeCaret() { return ShowNativeCaret(false); }
+
// Implementation from now on
// --------------------------
// EDIT control has one already)
void OnRightClick(wxMouseEvent& event);
+ // be sure the caret remains invisible if the user
+ // called HideNativeCaret() before
+ void OnSetFocus(wxFocusEvent& event);
+
protected:
// common part of all ctors
void Init();
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
wxMenu* m_privateContextMenu;
+
+ bool m_isNativeCaretShown;
};
#endif
#ifdef __WIN16__
EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
#endif
+
+ EVT_SET_FOCUS(wxTextCtrl::OnSetFocus)
END_EVENT_TABLE()
// ============================================================================
m_privateContextMenu = NULL;
m_suppressNextUpdate = FALSE;
+ m_isNativeCaretShown = true;
}
wxTextCtrl::~wxTextCtrl()
return ::SendMessage(GetHwnd(), EM_CANUNDO, 0, 0) != 0;
}
+// ----------------------------------------------------------------------------
+// caret handling (Windows only)
+// ----------------------------------------------------------------------------
+
+bool wxTextCtrl::ShowNativeCaret(bool show)
+{
+ if ( show != m_isNativeCaretShown )
+ {
+ if ( !(show ? ::ShowCaret(GetHwnd()) : ::HideCaret(GetHwnd())) )
+ {
+ // not an error, may simply indicate that it's not shown/hidden
+ // yet (i.e. it had been hidden/showh 2 times before)
+ return false;
+ }
+
+ m_isNativeCaretShown = show;
+ }
+
+ return true;
+}
+
// ----------------------------------------------------------------------------
// implemenation details
// ----------------------------------------------------------------------------
event.Skip();
}
+void wxTextCtrl::OnSetFocus(wxFocusEvent& event)
+{
+ // be sure the caret remains invisible if the user had hidden it
+ if ( !m_isNativeCaretShown )
+ {
+ ::HideCaret(GetHwnd());
+ }
+}
+
// the rest of the file only deals with the rich edit controls
#if wxUSE_RICHEDIT