瀏覽代碼

fix error when mouse event fires on text field withour current renderer

Kolja Strohm 3 年之前
父節點
當前提交
c745d98f84
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      TextFeld.cpp

+ 3 - 1
TextFeld.cpp

@@ -1604,7 +1604,7 @@ bool TextFeld::isCharSelected( int index ) const
 //  return: -1, falls sich an der Position kein zeichen befindet
 int TextFeld::getTextIndexAt( int mx, int my ) const
 {
-    if( !tm || !tm->text )
+    if( !tm || !tm->text || !tm->zCurrentRenderer() )
         return -1;
     int tbr = getTextWidth();
     int thi = getTextHeight();
@@ -1655,6 +1655,8 @@ int TextFeld::getTextIndexAt( int mx, int my ) const
 //  my: die y position der maus relativ zut position des textfeldes
 int TextFeld::getCurserPosAt( int mx, int my ) const
 {
+    if( !tm || !tm->text || !tm->zCurrentRenderer() )
+        return tm->text->getLength();
     int tbr = getTextWidth();
     int thi = getTextHeight();
     int xxx = 0;