Bladeren bron

fix cursor rendering in text fields

Kolja Strohm 9 maanden geleden
bovenliggende
commit
71574ab01f
1 gewijzigde bestanden met toevoegingen van 10 en 6 verwijderingen
  1. 10 6
      TextFeld.cpp

+ 10 - 6
TextFeld.cpp

@@ -1493,9 +1493,7 @@ void TextFeld::render(Bild& zRObj) // zeichenet nach zRObj
     if (vs) yyy -= vertikalScrollBar->getScroll();
     if (hs) xxx -= horizontalScrollBar->getScroll();
     if (hatStyle(Style::HCenter) && !hs) xxx = (breite / 2) - tbr / 2;
-    if (hatStyle(Style::VCenter) && !vs) yyy = (height / 2) - thi / 2;
     int x = xxx;
-    int y = yyy;
     int len = tm->text->getLength();
     const char* text = tm->text->getText();
     Text txtWithLineBreaks;
@@ -1508,16 +1506,18 @@ void TextFeld::render(Bild& zRObj) // zeichenet nach zRObj
     }
     lockZeichnung();
     tm->resetIteration();
+    if (thi == 0)
+    {
+        thi = tm->zCurrentRenderer()->getZeilenHeight();
+    }
+    if (hatStyle(Style::VCenter) && !vs) yyy = (height / 2) - thi / 2;
+    int y = yyy;
     TextStyle& style = tm->currentStyle();
     int maxLH = 0;
     int corrector = 0;
     int realLen = tm->text->getLength();
     for (int i = 0; i <= len; i++)
     {
-        if (i >= realLen || text[i] != tm->text->getText()[i])
-        {
-            corrector++;
-        }
         int oldX = x;
         if (i < len && tm->zCurrentRenderer())
             tm->zCurrentRenderer()->renderChar(x,
@@ -1532,6 +1532,10 @@ void TextFeld::render(Bild& zRObj) // zeichenet nach zRObj
             && hatStyle(Style::Editierbar) && tm->zCurrentRenderer())
             zRObj.drawLinieV(
                 oldX, y, tm->zCurrentRenderer()->getZeilenHeight(), 0xFFFF5555);
+        if (i >= realLen || text[i] != tm->text->getText()[i])
+        {
+            corrector++;
+        }
         if (tm->zCurrentRenderer())
         {
             int tmp = tm->zCurrentRenderer()->getZeilenHeight()