From: Jean-Marc Lasgouttes Date: Tue, 12 Aug 2008 10:17:31 +0000 (+0000) Subject: Fix bug 5161: Context menu does not respect selection X-Git-Tag: 1.6.10~3682 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2d76d3a0c6459ffc8206afad8459988e855e8c1b;p=features.git Fix bug 5161: Context menu does not respect selection http://bugzilla.lyx.org/show_bug.cgi?id=5161 * Text3.cpp (dispatch/LFUN_MOUSE_PRESS): compare the mouse position to the bufferview cursor, since cur is already set to the place we want; reverse the test for being inside of the selection. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26121 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Text3.cpp b/src/Text3.cpp index 4b659d4a64..a34dde66e6 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1179,23 +1179,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) bv->cursor().finishUndo(); break; - case mouse_button::button3: - if (cur.selection()) { - DocIterator const selbeg = cur.selectionBegin(); - DocIterator const selend = cur.selectionEnd(); - Cursor tmpcur = cur; - tm.setCursorFromCoordinates(tmpcur, cmd.x, cmd.y); - // Don't do anything if we right-click a selection, a selection - // context menu should popup instead. - if (tmpcur < selbeg || tmpcur >= selend) { - cur.noUpdate(); - return; - } + case mouse_button::button3: { + Cursor const & bvcur = cur.bv().cursor(); + // Don't do anything if we right-click a + // selection, a context menu will popup. + if (bvcur.selection() && cur >= bvcur.selectionBegin() + && cur <= bvcur.selectionEnd()) { + cur.noUpdate(); + return; } - if (!bv->mouseSetCursor(cur, false)) { + if (!bv->mouseSetCursor(cur, false)) cur.updateFlags(Update::SinglePar | Update::FitCursor); - break; - } + break; + } + default: break; } // switch (cmd.button())