From f208cfc886ea6353fbf3ad7bb548aebb386fbec7 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 29 Jul 2017 22:02:58 +0200 Subject: [PATCH] Implement XYToPosition() for single-line wxTextCtrl (wxGTK) --- docs/changes.txt | 1 + src/gtk/textctrl.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index fee858998b..00996fb3d8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -162,6 +162,7 @@ wxGTK: - Fix wxMemoryDC::Blit() with itself as source (GTK+ 3). - Fix displaying labels of wxRadioBox items. - Add a native implementation for clearing bitmap/window wxGraphicsContexts +- Implement XYToPosition() for single-line wxTextCtrl. wxMSW: diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 5e4ec7e954..7f832eb658 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -1224,7 +1224,12 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const long wxTextCtrl::XYToPosition(long x, long y ) const { if ( IsSingleLine() ) - return 0; + { + if ( y != 0 || x >= gtk_entry_get_text_length(GTK_ENTRY(m_text)) ) + return -1; + + return x; + } GtkTextIter iter; if (y >= gtk_text_buffer_get_line_count (m_buffer))