[evolution] EHTMLEditorView - Selection is lost when showing context menu



commit 48d0d981ab76e2d5e5e77072b4b33f0d5b4c698c
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Mar 2 09:12:54 2015 +0100

    EHTMLEditorView - Selection is lost when showing context menu
    
    Only move to the pointer coordinates when the selection is collapsed.

 e-util/e-html-editor-view.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 43da38e..f8abcee 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -2692,15 +2692,21 @@ static gboolean
 html_editor_view_button_press_event (GtkWidget *widget,
                                      GdkEventButton *event)
 {
-       gboolean event_handled;
+       gboolean event_handled, collapsed;
+       EHTMLEditorSelection *selection;
+
+       selection = e_html_editor_view_get_selection (E_HTML_EDITOR_VIEW (widget));
+       collapsed = e_html_editor_selection_is_collapsed (selection);
 
        if (event->button == 2) {
                /* Middle click paste */
-               html_editor_view_move_selection_on_point (widget);
+               if (collapsed)
+                       html_editor_view_move_selection_on_point (widget);
                g_signal_emit (widget, signals[PASTE_PRIMARY_CLIPBOARD], 0);
                event_handled = TRUE;
        } else if (event->button == 3) {
-               html_editor_view_move_selection_on_point (widget);
+               if (collapsed)
+                       html_editor_view_move_selection_on_point (widget);
                g_signal_emit (
                        widget, signals[POPUP_EVENT],
                        0, event, &event_handled);
@@ -3102,9 +3108,15 @@ html_editor_view_key_press_event (GtkWidget *widget,
        EHTMLEditorView *view = E_HTML_EDITOR_VIEW (widget);
 
        if (event->keyval == GDK_KEY_Menu) {
-               gboolean event_handled;
+               gboolean event_handled, collapsed;
+               EHTMLEditorSelection *selection;
+
+               selection = e_html_editor_view_get_selection (E_HTML_EDITOR_VIEW (widget));
+               collapsed = e_html_editor_selection_is_collapsed (selection);
+
+               if (collapsed)
+                       html_editor_view_move_selection_on_point (widget);
 
-               html_editor_view_move_selection_on_point (widget);
                g_signal_emit (
                        widget, signals[POPUP_EVENT],
                        0, event, &event_handled);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]