From 97f0a22a8bb77718b6c8e1f304122d493cdce2ca Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 12 Feb 2013 12:09:49 +0000 Subject: Tidy textarea-handled mouse action. --- desktop/textarea.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/desktop/textarea.c b/desktop/textarea.c index bb0ed310c..a1c422202 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -2190,16 +2190,22 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, } } - /* mouse button pressed above the text area, move caret */ - if (mouse & BROWSER_MOUSE_PRESS_1) { + /* Mouse action is textarea's responsibility */ + if (mouse & BROWSER_MOUSE_DOUBLE_CLICK) { + /* Select word */ + textarea_set_caret_xy(ta, x, y); + return textarea_select_fragment(ta); + + } else if (mouse & BROWSER_MOUSE_PRESS_1) { if (!(ta->flags & TEXTAREA_READONLY)) { + /* Place caret */ textarea_get_xy_offset(ta, x, y, &c_off); ta->drag_start_char = c_off; textarea_set_caret(ta, c_off); } if (ta->sel_start != -1) { - /* remove selection */ + /* Clear selection */ ta->sel_start = ta->sel_end = -1; msg.ta = ta; @@ -2212,12 +2218,6 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, ta->callback(ta->data, &msg); } - } else if (mouse & BROWSER_MOUSE_DOUBLE_CLICK) { - if (!(ta->flags & TEXTAREA_READONLY)) { - textarea_set_caret_xy(ta, x, y); - return textarea_select_fragment(ta); - } - } else if (mouse & BROWSER_MOUSE_DRAG_1) { /* Selection start */ textarea_get_xy_offset(ta, x, y, &c_off); @@ -2232,6 +2232,7 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, ta->callback(ta->data, &msg); return textarea_select(ta, c_start, c_end, false); + } else if (mouse & BROWSER_MOUSE_HOLDING_1 && ta->drag_info.type == TEXTAREA_DRAG_SELECTION) { /* Selection track */ -- cgit v1.2.3