Author: manolo
Date: 2012-12-20 07:46:41 -0800 (Thu, 20 Dec 2012)
New Revision: 9771
Log:
Mac OS text input: corrected minor issue when text widget is in a subwindow.

Modified:
   branches/branch-3.0/src/fltk3/cocoa.mm

Modified: branches/branch-3.0/src/fltk3/cocoa.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa.mm      2012-12-20 15:12:32 UTC (rev 
9770)
+++ branches/branch-3.0/src/fltk3/cocoa.mm      2012-12-20 15:46:41 UTC (rev 
9771)
@@ -1982,18 +1982,24 @@
   if (!focus) focus = wfocus;
   glyphRect.size.width = 0;
   
-  if (dynamic_cast<fltk3::TextDisplay*>(focus) != NULL) {
+  fltk3::TextDisplay *current = dynamic_cast<fltk3::TextDisplay*>(focus);
+  if (current) {
     int x, y;
-    fltk3::TextDisplay *current = (fltk3::TextDisplay*)focus;
     current->position_to_xy( current->insert_position(), &x, &y );
     glyphRect.origin.x = (CGFloat)x;
     glyphRect.origin.y = (CGFloat)y + current->textsize();
     glyphRect.size.height = current->textsize();
   } else {
-    glyphRect.origin.x = focus->x();
-    glyphRect.origin.y = focus->y() + focus->h();
+    glyphRect.origin.x = 0;
+    glyphRect.origin.y = focus->h();
     glyphRect.size.height = 12;
   }
+  fltk3::Widget *w = focus;
+  while (w->parent()) {
+    glyphRect.origin.x += w->x();
+    glyphRect.origin.y += w->y();
+    w = w->parent();
+  }
   // Convert the rect to screen coordinates
   glyphRect.origin.y = wfocus->h() - glyphRect.origin.y;
   glyphRect.origin = [[self window] convertBaseToScreen:glyphRect.origin];

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to