Avoid invisible caret on wxOSX because of hiding the caret multiple times

This commit is contained in:
JulianSmart
2015-11-13 15:44:03 +00:00
parent 6602eb3384
commit 308727daed

View File

@@ -540,6 +540,7 @@ void wxRichTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event))
#if !wxRICHTEXT_USE_OWN_CARET #if !wxRICHTEXT_USE_OWN_CARET
PositionCaret(); PositionCaret();
#endif #endif
if (!GetCaret()->IsVisible())
GetCaret()->Show(); GetCaret()->Show();
} }
@@ -554,7 +555,7 @@ void wxRichTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event))
void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event)) void wxRichTextCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event))
{ {
if (GetCaret()) if (GetCaret() && GetCaret()->IsVisible())
GetCaret()->Hide(); GetCaret()->Hide();
#if defined(__WXGTK__) && !wxRICHTEXT_USE_OWN_CARET #if defined(__WXGTK__) && !wxRICHTEXT_USE_OWN_CARET
@@ -2856,6 +2857,7 @@ void wxRichTextCtrl::OnIdle(wxIdleEvent& event)
{ {
((wxRichTextCaret*) GetCaret())->SetNeedsUpdate(false); ((wxRichTextCaret*) GetCaret())->SetNeedsUpdate(false);
PositionCaret(); PositionCaret();
if (!GetCaret()->IsVisible())
GetCaret()->Show(); GetCaret()->Show();
} }
#endif #endif
@@ -2898,6 +2900,7 @@ void wxRichTextCtrl::OnScroll(wxScrollWinEvent& event)
#if wxRICHTEXT_USE_OWN_CARET #if wxRICHTEXT_USE_OWN_CARET
if (!((wxRichTextCaret*) GetCaret())->GetNeedsUpdate()) if (!((wxRichTextCaret*) GetCaret())->GetNeedsUpdate())
{ {
if (GetCaret()->IsVisible())
GetCaret()->Hide(); GetCaret()->Hide();
((wxRichTextCaret*) GetCaret())->SetNeedsUpdate(); ((wxRichTextCaret*) GetCaret())->SetNeedsUpdate();
} }
@@ -5419,6 +5422,7 @@ void wxRichTextCaret::Notify()
// Workaround for lack of kill focus event in wxOSX // Workaround for lack of kill focus event in wxOSX
if (m_richTextCtrl && !m_richTextCtrl->HasFocus()) if (m_richTextCtrl && !m_richTextCtrl->HasFocus())
{ {
if (IsVisible())
Hide(); Hide();
return; return;
} }