From: Jean-Marc Lasgouttes Date: Tue, 12 Aug 2008 14:13:16 +0000 (+0000) Subject: Fix bug 4166: Crash when middle button click on inset label X-Git-Tag: 1.6.10~3681 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=45312b5f491734c5f35b920ed5e88bdd1ee7fa33;p=features.git Fix bug 4166: Crash when middle button click on inset label http://bugzilla.lyx.org/show_bug.cgi?id=4662 * InsetCollapsable.cpp (doDispatch): cleanup the handling of mouse- related lfuns. The new behavior is as follows: - everything that does not touch the button is sent to the insettext, if it is visible, and delegated to enclosing inset instead - mouse1-press is delegated to enclosing inset (which will set the cursor) - the rest is either acted upon or results on a mere cur.noUpdate(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26122 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index b31beff245..221b8f3bbd 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -425,7 +425,7 @@ void InsetCollapsable::cursorPos(BufferView const & bv, Inset::EDITABLE InsetCollapsable::editable() const { - return geometry() != ButtonOnly? HIGHLY_EDITABLE : IS_EDITABLE; + return geometry() != ButtonOnly ? HIGHLY_EDITABLE : IS_EDITABLE; } @@ -489,28 +489,23 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_MOUSE_PRESS: - if (hitButton(cmd) && geometry() != NoButton) { + if (hitButton(cmd)) { switch (cmd.button()) { case mouse_button::button1: - // reset selection if necessary (see bug 3060) - if (cur.selection()) - cur.bv().cursor().clearSelection(); - else - cur.noUpdate(); - cur.dispatched(); - return; + // Pass the command to the enclosing InsetText, + // so that the cursor gets set. + cur.undispatched(); + break; case mouse_button::none: case mouse_button::button2: case mouse_button::button3: case mouse_button::button4: case mouse_button::button5: // Nothing to do. - cur.undispatched(); - return; + cur.noUpdate(); + break; } - } - if (geometry() == NoButton - || (geometry() != ButtonOnly && !hitButton(cmd))) + } else if (geometry() != ButtonOnly) InsetText::doDispatch(cur, cmd); else cur.undispatched(); @@ -519,24 +514,26 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_MOUSE_MOTION: case LFUN_MOUSE_DOUBLE: case LFUN_MOUSE_TRIPLE: - if (geometry() == NoButton) - InsetText::doDispatch(cur, cmd); - else if (geometry() != ButtonOnly - && !hitButton(cmd)) + if (hitButton(cmd)) + cur.noUpdate(); + else if (geometry() != ButtonOnly) InsetText::doDispatch(cur, cmd); else cur.undispatched(); break; case LFUN_MOUSE_RELEASE: - if (geometry() == NoButton - || (geometry() != ButtonOnly && !hitButton(cmd))) { + if (!hitButton(cmd)) { // The mouse click has to be within the inset! - InsetText::doDispatch(cur, cmd); + if (geometry() != ButtonOnly) + InsetText::doDispatch(cur, cmd); + else + cur.undispatched(); break; } if (cmd.button() != mouse_button::button1) { - cur.dispatched(); + // Nothing to do. + cur.noUpdate(); break; } // if we are selecting, we do not want to diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index c447db086d..1ef00985b8 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -68,7 +68,9 @@ public: void cursorPos(BufferView const & bv, CursorSlice const & sl, /// bool boundary, int & x, int & y) const; - /// + /// Returns true if (mouse) action is over the inset's button. + /// Always returns false when the inset does not have a + /// button. bool hitButton(FuncRequest const &) const; /// docstring const getNewLabel(docstring const & l) const;