mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-11 16:31:09 +00:00
Cleanup mouse/selection/context-menu interactions.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23944 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
678a72f549
commit
fb25ff1819
154
src/Text3.cpp
154
src/Text3.cpp
@ -1134,51 +1134,63 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Single-click on work area
|
// Single-click on work area
|
||||||
case LFUN_MOUSE_PRESS: {
|
case LFUN_MOUSE_PRESS:
|
||||||
// Right click on a footnote flag opens float menu
|
// We are not marking a selection with the keyboard in any case.
|
||||||
// FIXME: Why should we clear the selection in this case?
|
cur.bv().cursor().mark() = false;
|
||||||
if (cmd.button() == mouse_button::button3)
|
switch (cmd.button()) {
|
||||||
cur.clearSelection();
|
case mouse_button::button1:
|
||||||
|
// Set the cursor
|
||||||
|
if (!bv->mouseSetCursor(cur, cmd.argument() == "region-select"))
|
||||||
|
cur.updateFlags(Update::SinglePar | Update::FitCursor);
|
||||||
|
break;
|
||||||
|
|
||||||
bool do_selection = cmd.button() == mouse_button::button1
|
case mouse_button::button2:
|
||||||
&& cmd.argument() == "region-select";
|
// Middle mouse pasting.
|
||||||
// Set the cursor
|
if (!cap::selection()) {
|
||||||
bool update = bv->mouseSetCursor(cur, do_selection);
|
// There is no local selection in the current buffer, so try to
|
||||||
|
// paste primary selection instead.
|
||||||
// Insert primary selection with middle mouse
|
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
|
||||||
// if there is a local selection in the current buffer,
|
"paragraph"));
|
||||||
// insert this
|
// Nothing else to do.
|
||||||
if (cmd.button() == mouse_button::button2) {
|
cur.noUpdate();
|
||||||
if (cap::selection()) {
|
return;
|
||||||
// Copy the selection buffer to the clipboard
|
|
||||||
// stack, because we want it to appear in the
|
|
||||||
// "Edit->Paste recent" menu.
|
|
||||||
cap::copySelectionToStack();
|
|
||||||
|
|
||||||
cap::pasteSelection(bv->cursor(),
|
|
||||||
bv->buffer().errorList("Paste"));
|
|
||||||
bv->buffer().errors("Paste");
|
|
||||||
bv->buffer().markDirty();
|
|
||||||
bv->cursor().finishUndo();
|
|
||||||
} else {
|
|
||||||
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
|
|
||||||
}
|
}
|
||||||
}
|
// Copy the selection buffer to the clipboard stack, because we want it
|
||||||
|
// to appear in the "Edit->Paste recent" menu.
|
||||||
|
cap::copySelectionToStack();
|
||||||
|
cap::pasteSelection(bv->cursor(), bv->buffer().errorList("Paste"));
|
||||||
|
cur.updateFlags(Update::Force | Update::FitCursor);
|
||||||
|
bv->buffer().errors("Paste");
|
||||||
|
bv->buffer().markDirty();
|
||||||
|
bv->cursor().finishUndo();
|
||||||
|
break;
|
||||||
|
|
||||||
// we have to update after dEPM triggered
|
case mouse_button::button3:
|
||||||
if (!update && cmd.button() == mouse_button::button1) {
|
if (cur.selection()) {
|
||||||
needsUpdate = false;
|
DocIterator const selbeg = cur.selectionBegin();
|
||||||
cur.noUpdate();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bv->mouseSetCursor(cur, false)) {
|
||||||
|
cur.noUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_MOUSE_MOTION: {
|
case LFUN_MOUSE_MOTION: {
|
||||||
// Only use motion with button 1
|
// Mouse motion with right or middle mouse do nothing for now.
|
||||||
//if (cmd.button() != mouse_button::button1)
|
if (cmd.button() != mouse_button::button1) {
|
||||||
// return false;
|
cur.noUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// ignore motions deeper nested than the real anchor
|
// ignore motions deeper nested than the real anchor
|
||||||
Cursor & bvcur = cur.bv().cursor();
|
Cursor & bvcur = cur.bv().cursor();
|
||||||
if (!bvcur.anchor_.hasPart(cur)) {
|
if (!bvcur.anchor_.hasPart(cur)) {
|
||||||
@ -1203,42 +1215,52 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
else if (cmd.y < 0)
|
else if (cmd.y < 0)
|
||||||
lyx::dispatch(FuncRequest(LFUN_UP_SELECT));
|
lyx::dispatch(FuncRequest(LFUN_UP_SELECT));
|
||||||
}
|
}
|
||||||
|
// We continue with our existing selection or start a new one, so don't
|
||||||
if (cur.top() == old)
|
// reset the anchor.
|
||||||
cur.noUpdate();
|
bvcur.setCursor(cur);
|
||||||
else {
|
bvcur.selection() = true;
|
||||||
// FIXME: This is brute force! But without it the selected
|
if (cur.top() == old) {
|
||||||
// area is not corrected updated while moving the mouse.
|
// We didn't move one iota, so no need to update the screen.
|
||||||
cur.updateFlags(Update::Force | Update::FitCursor);
|
cur.updateFlags(Update::SinglePar | Update::FitCursor);
|
||||||
// don't set anchor_
|
//cur.noUpdate();
|
||||||
bvcur.setCursor(cur);
|
return;
|
||||||
bvcur.selection() = true;
|
|
||||||
//lyxerr << "MOTION: " << bv->cursor() << endl;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE: {
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (cmd.button() == mouse_button::button2)
|
switch (cmd.button()) {
|
||||||
break;
|
case mouse_button::button1:
|
||||||
|
// Cursor was set at LFUN_MOUSE_PRESS or LFUN_MOUSE_MOTION time.
|
||||||
if (cmd.button() == mouse_button::button1) {
|
// If there is a new selection, update persistent selection;
|
||||||
// if there is new selection, update persistent
|
// otherwise, single click does not clear persistent selection
|
||||||
// selection, otherwise, single click does not
|
// buffer.
|
||||||
// clear persistent selection buffer
|
|
||||||
if (cur.selection()) {
|
if (cur.selection()) {
|
||||||
// finish selection
|
// Finish selection.
|
||||||
// if double click, cur is moved to the end of word by selectWord
|
// If double click, cur is moved to the end of word by selectWord
|
||||||
// but bvcur is current mouse position
|
// but bvcur is current mouse position.
|
||||||
Cursor & bvcur = cur.bv().cursor();
|
cur.bv().cursor().selection() = true;
|
||||||
bvcur.selection() = true;
|
|
||||||
}
|
}
|
||||||
needsUpdate = false;
|
// FIXME: We could try to handle drag and drop of selection here.
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
case mouse_button::button2:
|
||||||
|
// Middle mouse pasting is handled at mouse press time,
|
||||||
|
// see LFUN_MOUSE_PRESS.
|
||||||
|
cur.noUpdate();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case mouse_button::button3:
|
||||||
|
// Cursor was set at LFUN_MOUSE_PRESS time.
|
||||||
|
// FIXME: If there is a selection we could try to handle a special
|
||||||
|
// drag & drop context menu.
|
||||||
|
cur.noUpdate();
|
||||||
|
return;
|
||||||
|
|
||||||
|
} // switch (cmd.button())
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case LFUN_SELF_INSERT: {
|
case LFUN_SELF_INSERT: {
|
||||||
if (cmd.argument().empty())
|
if (cmd.argument().empty())
|
||||||
|
@ -198,14 +198,6 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
InsetBoxMailer(*this).updateDialog(&cur.bv());
|
InsetBoxMailer(*this).updateDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
|
||||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
|
||||||
InsetBoxMailer(*this).showDialog(&cur.bv());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
InsetCollapsable::doDispatch(cur, cmd);
|
||||||
break;
|
break;
|
||||||
|
@ -130,14 +130,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
InsetBranchMailer(*this).updateDialog(&cur.bv());
|
InsetBranchMailer(*this).updateDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
|
||||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd))
|
|
||||||
InsetBranchMailer(*this).showDialog(&cur.bv());
|
|
||||||
else
|
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case LFUN_INSET_TOGGLE:
|
case LFUN_INSET_TOGGLE:
|
||||||
if (cmd.argument() == "assign") {
|
if (cmd.argument() == "assign") {
|
||||||
// The branch inset uses "assign".
|
// The branch inset uses "assign".
|
||||||
|
@ -497,21 +497,25 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
if (cmd.button() == mouse_button::button1
|
if (hitButton(cmd) && geometry() != NoButton) {
|
||||||
&& hitButton(cmd)
|
switch (cmd.button()) {
|
||||||
&& geometry() != NoButton) {
|
case mouse_button::button1:
|
||||||
// reset selection if necessary (see bug 3060)
|
// reset selection if necessary (see bug 3060)
|
||||||
if (cur.selection())
|
if (cur.selection())
|
||||||
cur.bv().cursor().clearSelection();
|
cur.bv().cursor().clearSelection();
|
||||||
else
|
else
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
cur.dispatched();
|
cur.dispatched();
|
||||||
break;
|
return;
|
||||||
|
case mouse_button::button2:
|
||||||
|
case mouse_button::button3:
|
||||||
|
// Nothing to do.
|
||||||
|
cur.undispatched();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (geometry() == NoButton)
|
if (geometry() == NoButton
|
||||||
InsetText::doDispatch(cur, cmd);
|
|| (geometry() != ButtonOnly && !hitButton(cmd)))
|
||||||
else if (geometry() != ButtonOnly
|
|
||||||
&& !hitButton(cmd))
|
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
else
|
else
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
@ -530,26 +534,6 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (cmd.button() == mouse_button::button3) {
|
|
||||||
// There is no button to right click:
|
|
||||||
if (decoration() == InsetLayout::Minimalistic ||
|
|
||||||
geometry() == Corners ||
|
|
||||||
geometry() == SubLabel ||
|
|
||||||
geometry() == NoButton
|
|
||||||
) {
|
|
||||||
if (status_ == Open)
|
|
||||||
setStatus(cur, Collapsed);
|
|
||||||
else
|
|
||||||
setStatus(cur, Open);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// Open the Inset
|
|
||||||
// configuration dialog
|
|
||||||
showInsetDialog(&cur.bv());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (geometry() == NoButton) {
|
if (geometry() == NoButton) {
|
||||||
// The mouse click has to be within the inset!
|
// The mouse click has to be within the inset!
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
|
@ -107,16 +107,6 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
Layout const layout = bp.documentClass().emptyLayout();
|
Layout const layout = bp.documentClass().emptyLayout();
|
||||||
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_MOUSE_PRESS:
|
|
||||||
if (cmd.button() != mouse_button::button3)
|
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
|
||||||
else
|
|
||||||
// This makes the cursor leave the
|
|
||||||
// inset when it collapses on mouse-3
|
|
||||||
cur.undispatched();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_QUOTE_INSERT: {
|
case LFUN_QUOTE_INSERT: {
|
||||||
// We need to bypass the fancy quotes in Text
|
// We need to bypass the fancy quotes in Text
|
||||||
FuncRequest f(LFUN_SELF_INSERT, "\"");
|
FuncRequest f(LFUN_SELF_INSERT, "\"");
|
||||||
|
@ -471,7 +471,7 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (!cur.selection())
|
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||||
InsetExternalMailer(*this).showDialog(&cur.bv());
|
InsetExternalMailer(*this).showDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -146,17 +146,6 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE: {
|
|
||||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
|
||||||
if (params_.subfloat)
|
|
||||||
break;
|
|
||||||
InsetFloatMailer(*this).showDialog(&cur.bv());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
InsetCollapsable::doDispatch(cur, cmd);
|
||||||
break;
|
break;
|
||||||
|
@ -197,7 +197,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (!cur.selection())
|
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||||
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -214,14 +214,6 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_INSET_DIALOG_UPDATE:
|
case LFUN_INSET_DIALOG_UPDATE:
|
||||||
InsetListingsMailer(*this).updateDialog(&cur.bv());
|
InsetListingsMailer(*this).updateDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
case LFUN_MOUSE_RELEASE: {
|
|
||||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
|
||||||
InsetListingsMailer(*this).showDialog(&cur.bv());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
InsetCollapsable::doDispatch(cur, cmd);
|
||||||
break;
|
break;
|
||||||
|
@ -132,7 +132,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (!cur.selection())
|
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||||
InsetSpaceMailer(*this).showDialog(&cur.bv());
|
InsetSpaceMailer(*this).showDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3179,12 +3179,6 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
|
||||||
//lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
|
|
||||||
if (cmd.button() == mouse_button::button3)
|
|
||||||
InsetTabularMailer(*this).showDialog(&cur.bv());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_CELL_BACKWARD:
|
case LFUN_CELL_BACKWARD:
|
||||||
movePrevCell(cur);
|
movePrevCell(cur);
|
||||||
cur.selection() = false;
|
cur.selection() = false;
|
||||||
|
@ -424,6 +424,11 @@ ParagraphList & InsetText::paragraphs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//void InsetInclude::addToToc(ParConstIterator const & cpit) const
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
void InsetText::updateLabels(ParIterator const & it)
|
void InsetText::updateLabels(ParIterator const & it)
|
||||||
{
|
{
|
||||||
ParIterator it2 = it;
|
ParIterator it2 = it;
|
||||||
|
@ -62,7 +62,7 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (!cur.selection())
|
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||||
InsetVSpaceMailer(*this).showDialog(&cur.bv());
|
InsetVSpaceMailer(*this).showDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -74,15 +74,6 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
InsetWrapMailer(*this).updateDialog(&cur.bv());
|
InsetWrapMailer(*this).updateDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE: {
|
|
||||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
|
||||||
InsetWrapMailer(*this).showDialog(&cur.bv());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
InsetCollapsable::doDispatch(cur, cmd);
|
InsetCollapsable::doDispatch(cur, cmd);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user