Bugfix: text buttons in zoomed in or out views, didn't get the cursor on the
authorTon Roosendaal <ton@blender.org>
Sun, 18 Apr 2010 17:05:55 +0000 (17:05 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 18 Apr 2010 17:05:55 +0000 (17:05 +0000)
right location for mouseclicks.

source/blender/editors/interface/interface_handlers.c

index 950975de2ab3f76b2dc954bf5fe5f13db9f2d324..258a9e545106b452ad91e02fa67d1e8e3f3b4df9 100644 (file)
@@ -1150,6 +1150,7 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
        return change;
 }
 
+/* note, but->block->aspect is used here, when drawing button style is getting scaled too */
 static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, short x)
 {
        uiStyle *style= U.uistyles.first;       // XXX pass on as arg
@@ -1190,10 +1191,12 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
        }
        /* mouse inside the widget */
        else if (x >= startx) {
+               float aspect= sqrt(but->block->aspect);
+               
                but->pos= strlen(origstr)-but->ofs;
                
                /* XXX does not take zoom level into account */
-               while (startx + BLF_width(origstr+but->ofs) > x) {
+               while (aspect*startx + aspect*BLF_width(origstr+but->ofs) > x) {
                        if (but->pos <= 0) break;
                        but->pos--;
                        origstr[but->pos+but->ofs] = 0;