added Show/HideNativeCaret() (patch 759924)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
974931fefa
commit
e3a6a6b2bc
@ -128,6 +128,11 @@ public:
|
||||
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
|
||||
// --------------------------
|
||||
|
||||
@ -184,6 +189,10 @@ public:
|
||||
// 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();
|
||||
@ -245,6 +254,8 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||
|
||||
wxMenu* m_privateContextMenu;
|
||||
|
||||
bool m_isNativeCaretShown;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -144,6 +144,8 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
#ifdef __WIN16__
|
||||
EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
|
||||
#endif
|
||||
|
||||
EVT_SET_FOCUS(wxTextCtrl::OnSetFocus)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
@ -162,6 +164,7 @@ void wxTextCtrl::Init()
|
||||
|
||||
m_privateContextMenu = NULL;
|
||||
m_suppressNextUpdate = FALSE;
|
||||
m_isNativeCaretShown = true;
|
||||
}
|
||||
|
||||
wxTextCtrl::~wxTextCtrl()
|
||||
@ -1240,6 +1243,27 @@ bool wxTextCtrl::CanRedo() const
|
||||
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
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1711,6 +1735,15 @@ void wxTextCtrl::OnRightClick(wxMouseEvent& event)
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user