From 7463d514bfc389cb26650661de2e06b4f7842895 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 10 Mar 2022 16:18:20 +0100 Subject: [PATCH] Fix text drawing in caret sample with wxGTK3 and wxOSX Don't use wxClientDC for drawing the text, just refresh the updated character. See #17820. --- samples/caret/caret.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index 815cab4527..ea882a7880 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -473,12 +473,12 @@ void MyCanvas::OnChar( wxKeyEvent &event ) wxChar ch = (wxChar)event.GetKeyCode(); CharAt(m_xCaret, m_yCaret) = ch; - wxCaretSuspend cs(this); - wxClientDC dc(this); - dc.SetFont(m_font); - dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); // overwrite old value - dc.DrawText(ch, m_xMargin + m_xCaret * m_widthChar, - m_yMargin + m_yCaret * m_heightChar ); + wxRect rect( + m_xMargin + m_xCaret * m_widthChar, + m_yMargin + m_yCaret * m_heightChar, + m_widthChar, + m_heightChar); + RefreshRect(rect, false /* don't erase background */); NextChar(); }