From 3123ad12a395031a1bf5a964582762a3831e9b1c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 16 Jan 2012 10:48:52 +0000 Subject: middle mouse jump scrolling for text window. --- source/blender/editors/space_text/space_text.c | 4 +++- source/blender/editors/space_text/text_ops.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_text') diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 23d12385625..441a5eab976 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -357,9 +357,11 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_overwrite_toggle", INSERTKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", MIDDLEMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TEXT_OT_scroll", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll", MOUSEPAN, 0, 0, 0); - WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_selection_set", EVT_TWEAK_L, KM_ANY, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_selection_set", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select", 1); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index e8ad6e19fd4..19f0c9bba61 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2232,8 +2232,8 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, wmEvent *event) text_scroll_apply(C, op, event); scroll_exit(C, op); return OPERATOR_FINISHED; - } - + } + WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -2314,9 +2314,20 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) tsc->scrollbar= 1; tsc->zone= zone; op->customdata= tsc; - st->flags|= ST_SCROLL_SELECT; + /* jump scroll, works in v2d but needs to be added here too :S */ + if (event->type == MIDDLEMOUSE) { + tsc->old[0] = ar->winrct.xmin + (st->txtbar.xmax + st->txtbar.xmin) / 2; + tsc->old[1] = ar->winrct.ymin + (st->txtbar.ymax + st->txtbar.ymin) / 2; + + tsc->delta[0] = 0; + tsc->delta[1] = 0; + tsc->first = 0; + tsc->zone= SCROLLHANDLE_BAR; + text_scroll_apply(C, op, event); + } + WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; -- cgit v1.2.3