diff options
author | Matt Ebb <matt@mke3.net> | 2010-03-08 15:35:59 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-03-08 15:35:59 +0300 |
commit | cb20ed16343482b1d52952d8ecf885a418908dc0 (patch) | |
tree | 04b8100d27028728002d8e36cd236aa4b2e069b1 /source | |
parent | 9ce5be370632449b0fe617348298b0eed3ed1b60 (diff) |
Fix [#21469] long paths can't be scrolled with the mouse
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8eb3132921d..9cf7edf2023 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1155,7 +1155,6 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho origstr= MEM_callocN(sizeof(char)*data->maxlen, "ui_textedit origstr"); BLI_strncpy(origstr, but->drawstr, data->maxlen); - but->pos= strlen(origstr)-but->ofs; /* XXX solve generic */ if(but->type==NUM || but->type==NUMSLI) @@ -1166,16 +1165,33 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho startx += 16; } - /* XXX does not take zoom level into account */ - while((BLF_width(origstr+but->ofs) + startx) > x) { - if (but->pos <= 0) break; - but->pos--; - origstr[but->pos+but->ofs] = 0; + /* mouse dragged outside the widget to the left */ + if (x < startx && but->ofs > 0) { + int i= but->ofs; + + origstr[but->ofs] = 0; + + while (i > 0) { + i--; + if (BLF_width(origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity + } + but->ofs = i; + but->pos = but->ofs; + } + /* mouse inside the widget */ + else if (x >= startx) { + but->pos= strlen(origstr)-but->ofs; + + /* XXX does not take zoom level into account */ + while (startx + BLF_width(origstr+but->ofs) > x) { + if (but->pos <= 0) break; + but->pos--; + origstr[but->pos+but->ofs] = 0; + } + but->pos += but->ofs; + if(but->pos<0) but->pos= 0; } - but->pos += but->ofs; - if(but->pos<0) but->pos= 0; - MEM_freeN(origstr); } |