diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-10 03:10:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-10 03:10:07 +0400 |
commit | 702e85ef849a2ad0a34ef0bd2d9f021e4a6e773f (patch) | |
tree | fd0b15b1ac8ffc7dd66dc559d2298c29ab664dc5 /source/blender/editors/space_text/text_ops.c | |
parent | a2e00c62303228ae85f54a2b8fffb8c5e071640e (diff) |
picky changes to mouse cursor text selection behavior, previously as soon as the mouse was before a character it would select the previous, even if the cursor was closer to the space between the next 2 chars.
now find the closest point inbetween both chars.
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 9fed3db7f16..17857275d36 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -73,6 +73,13 @@ /************************ poll ***************************/ + +BM_INLINE int text_pixel_x_to_index(SpaceText *st, const int x) +{ + /* add half the char width so mouse cursor selection is inbetween letters */ + return (x + (st->cwidth / 2)) / st->cwidth; +} + static int text_new_poll(bContext *UNUSED(C)) { return 1; @@ -2530,7 +2537,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int else x-= TXT_OFFSET; if(x<0) x= 0; - x = (x/st->cwidth) + st->left; + x = text_pixel_x_to_index(st, x) + st->left; if(st->wordwrap) { text_cursor_set_to_pos_wrapped(st, ar, x, y, sel); |