summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/textarea.c40
-rw-r--r--desktop/textarea.h8
-rw-r--r--riscos/window.c5
3 files changed, 36 insertions, 17 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 0426b007a..455e9a4ca 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -1934,10 +1934,7 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
case KEY_ESCAPE:
/* Fall through to KEY_CLEAR_SELECTION */
case KEY_CLEAR_SELECTION:
- ta->sel_start = -1;
- ta->sel_end = -1;
- redraw = true;
- break;
+ return textarea_clear_selection(ta);
case KEY_LEFT:
if (readonly)
break;
@@ -2272,16 +2269,7 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse,
}
if (ta->sel_start != -1) {
/* Clear selection */
- ta->sel_start = ta->sel_end = -1;
-
- msg.ta = ta;
- msg.type = TEXTAREA_MSG_REDRAW_REQUEST;
- msg.data.redraw.x0 = 0;
- msg.data.redraw.y0 = 0;
- msg.data.redraw.x1 = ta->vis_width;
- msg.data.redraw.y1 = ta->vis_height;
-
- ta->callback(ta->data, &msg);
+ textarea_clear_selection(ta);
}
} else if (mouse & BROWSER_MOUSE_PRESS_2) {
@@ -2350,6 +2338,30 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse,
/* exported interface, documented in textarea.h */
+bool textarea_clear_selection(struct textarea *ta)
+{
+ struct textarea_msg msg;
+
+ if (ta->sel_start == -1)
+ /* No selection to clear */
+ return false;
+
+ ta->sel_start = ta->sel_end = -1;
+
+ msg.ta = ta;
+ msg.type = TEXTAREA_MSG_REDRAW_REQUEST;
+ msg.data.redraw.x0 = 0;
+ msg.data.redraw.y0 = 0;
+ msg.data.redraw.x1 = ta->vis_width;
+ msg.data.redraw.y1 = ta->vis_height;
+
+ ta->callback(ta->data, &msg);
+
+ return true;
+}
+
+
+/* exported interface, documented in textarea.h */
void textarea_get_dimensions(struct textarea *ta, int *width, int *height)
{
if (width != NULL)
diff --git a/desktop/textarea.h b/desktop/textarea.h
index d01cd12c6..3fedeee35 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -198,6 +198,14 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse,
int x, int y);
/**
+ * Clear any selection in the textarea.
+ *
+ * \param ta textarea widget
+ * \return true if there was a selection to clear, false otherwise
+ */
+bool textarea_clear_selection(struct textarea *ta);
+
+/**
* Gets the dimensions of a textarea
*
* \param ta textarea widget
diff --git a/riscos/window.c b/riscos/window.c
index 23b2ee8d6..2ad5426e7 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1768,8 +1768,7 @@ bool ro_gui_window_click(wimp_pointer *pointer)
ro_gui_url_complete_close();
/* set input focus */
- if (pointer->buttons == wimp_CLICK_SELECT ||
- pointer->buttons == wimp_CLICK_ADJUST)
+ if (pointer->buttons & (wimp_SINGLE_SELECT | wimp_SINGLE_ADJUST))
gui_window_place_caret(g, -100, -100, 0);
if (ro_gui_window_to_window_pos(g, pointer->pos.x, pointer->pos.y, &pos))
@@ -4953,7 +4952,7 @@ browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
browser_mouse_state state = 0; /* Blank state with nothing set */
/* If mouse buttons aren't held, turn off drags */
- if (!(buttons & (wimp_CLICK_SELECT) || buttons & (wimp_CLICK_ADJUST))) {
+ if (!(buttons & (wimp_CLICK_SELECT | wimp_CLICK_ADJUST))) {
mouse_drag_select = false;
mouse_drag_adjust = false;
}