]> git.lyx.org Git - features.git/commitdiff
Fix InsetMathRef mouse behaviour (#10568)
authorGuillaume Munch <gm@lyx.org>
Sat, 18 Feb 2017 21:24:25 +0000 (22:24 +0100)
committerGuillaume Munch <gm@lyx.org>
Sat, 18 Feb 2017 22:03:54 +0000 (23:03 +0100)
Fix mouse-selection behaviour.

Don't open dialog when releasing if it was not a real click.

src/mathed/InsetMathRef.cpp

index ef08cbcd3d0610d95c8b9446e85b5959261822fe..22807f15b533a5be5eb829e192d0089ff0a125ad 100644 (file)
@@ -81,6 +81,10 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_MOUSE_RELEASE:
+               if (cur.selection()) {
+                       cur.undispatched();
+                       break;
+               }
                if (cmd.button() == mouse_button::button3) {
                        LYXERR0("trying to goto ref '" << to_utf8(asString(cell(0))) << "'");
                        //FIXME: use DispatchResult argument
@@ -96,8 +100,18 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.undispatched();
                break;
 
-       case LFUN_MOUSE_PRESS:
-       case LFUN_MOUSE_MOTION:
+       case LFUN_MOUSE_PRESS: {
+               bool do_selection = cmd.button() == mouse_button::button1
+                       && cmd.modifier() == ShiftModifier;
+               // For some reason the cursor points inside the first cell, which is not
+               // active.
+               cur.leaveInset(*this);
+               cur.bv().mouseSetCursor(cur, do_selection);
+               break;
+       }
+
+       case LFUN_MOUSE_DOUBLE:
+       case LFUN_MOUSE_TRIPLE:
                // eat other mouse commands
                break;
 
@@ -117,7 +131,8 @@ bool InsetMathRef::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_INSET_DIALOG_UPDATE:
        case LFUN_MOUSE_RELEASE:
        case LFUN_MOUSE_PRESS:
-       case LFUN_MOUSE_MOTION:
+       case LFUN_MOUSE_DOUBLE:
+       case LFUN_MOUSE_TRIPLE:
                status.setEnabled(true);
                return true;
        default: