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;
|
||||
|
||||
// Single-click on work area
|
||||
case LFUN_MOUSE_PRESS: {
|
||||
// Right click on a footnote flag opens float menu
|
||||
// FIXME: Why should we clear the selection in this case?
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
cur.clearSelection();
|
||||
case LFUN_MOUSE_PRESS:
|
||||
// We are not marking a selection with the keyboard in any case.
|
||||
cur.bv().cursor().mark() = false;
|
||||
switch (cmd.button()) {
|
||||
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
|
||||
&& cmd.argument() == "region-select";
|
||||
// Set the cursor
|
||||
bool update = bv->mouseSetCursor(cur, do_selection);
|
||||
|
||||
// Insert primary selection with middle mouse
|
||||
// if there is a local selection in the current buffer,
|
||||
// insert this
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
if (cap::selection()) {
|
||||
// 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"));
|
||||
case mouse_button::button2:
|
||||
// Middle mouse pasting.
|
||||
if (!cap::selection()) {
|
||||
// There is no local selection in the current buffer, so try to
|
||||
// paste primary selection instead.
|
||||
lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
|
||||
"paragraph"));
|
||||
// Nothing else to do.
|
||||
cur.noUpdate();
|
||||
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"));
|
||||
cur.updateFlags(Update::Force | Update::FitCursor);
|
||||
bv->buffer().errors("Paste");
|
||||
bv->buffer().markDirty();
|
||||
bv->cursor().finishUndo();
|
||||
break;
|
||||
|
||||
// we have to update after dEPM triggered
|
||||
if (!update && cmd.button() == mouse_button::button1) {
|
||||
needsUpdate = false;
|
||||
cur.noUpdate();
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (!bv->mouseSetCursor(cur, false)) {
|
||||
cur.noUpdate();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_MOTION: {
|
||||
// Only use motion with button 1
|
||||
//if (cmd.button() != mouse_button::button1)
|
||||
// return false;
|
||||
|
||||
// Mouse motion with right or middle mouse do nothing for now.
|
||||
if (cmd.button() != mouse_button::button1) {
|
||||
cur.noUpdate();
|
||||
return;
|
||||
}
|
||||
// ignore motions deeper nested than the real anchor
|
||||
Cursor & bvcur = cur.bv().cursor();
|
||||
if (!bvcur.anchor_.hasPart(cur)) {
|
||||
@ -1203,42 +1215,52 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
else if (cmd.y < 0)
|
||||
lyx::dispatch(FuncRequest(LFUN_UP_SELECT));
|
||||
}
|
||||
|
||||
if (cur.top() == old)
|
||||
cur.noUpdate();
|
||||
else {
|
||||
// FIXME: This is brute force! But without it the selected
|
||||
// area is not corrected updated while moving the mouse.
|
||||
cur.updateFlags(Update::Force | Update::FitCursor);
|
||||
// don't set anchor_
|
||||
bvcur.setCursor(cur);
|
||||
bvcur.selection() = true;
|
||||
//lyxerr << "MOTION: " << bv->cursor() << endl;
|
||||
// We continue with our existing selection or start a new one, so don't
|
||||
// reset the anchor.
|
||||
bvcur.setCursor(cur);
|
||||
bvcur.selection() = true;
|
||||
if (cur.top() == old) {
|
||||
// We didn't move one iota, so no need to update the screen.
|
||||
cur.updateFlags(Update::SinglePar | Update::FitCursor);
|
||||
//cur.noUpdate();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_RELEASE: {
|
||||
if (cmd.button() == mouse_button::button2)
|
||||
break;
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// if there is new selection, update persistent
|
||||
// selection, otherwise, single click does not
|
||||
// clear persistent selection buffer
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
switch (cmd.button()) {
|
||||
case mouse_button::button1:
|
||||
// Cursor was set at LFUN_MOUSE_PRESS or LFUN_MOUSE_MOTION time.
|
||||
// If there is a new selection, update persistent selection;
|
||||
// otherwise, single click does not clear persistent selection
|
||||
// buffer.
|
||||
if (cur.selection()) {
|
||||
// finish selection
|
||||
// if double click, cur is moved to the end of word by selectWord
|
||||
// but bvcur is current mouse position
|
||||
Cursor & bvcur = cur.bv().cursor();
|
||||
bvcur.selection() = true;
|
||||
// Finish selection.
|
||||
// If double click, cur is moved to the end of word by selectWord
|
||||
// but bvcur is current mouse position.
|
||||
cur.bv().cursor().selection() = true;
|
||||
}
|
||||
needsUpdate = false;
|
||||
// FIXME: We could try to handle drag and drop of selection here.
|
||||
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;
|
||||
}
|
||||
|
||||
case LFUN_SELF_INSERT: {
|
||||
if (cmd.argument().empty())
|
||||
|
@ -198,14 +198,6 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
InsetBoxMailer(*this).updateDialog(&cur.bv());
|
||||
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:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
|
@ -130,14 +130,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
InsetBranchMailer(*this).updateDialog(&cur.bv());
|
||||
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:
|
||||
if (cmd.argument() == "assign") {
|
||||
// The branch inset uses "assign".
|
||||
|
@ -497,21 +497,25 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() == mouse_button::button1
|
||||
&& hitButton(cmd)
|
||||
&& geometry() != NoButton) {
|
||||
// reset selection if necessary (see bug 3060)
|
||||
if (cur.selection())
|
||||
cur.bv().cursor().clearSelection();
|
||||
else
|
||||
cur.noUpdate();
|
||||
cur.dispatched();
|
||||
break;
|
||||
if (hitButton(cmd) && geometry() != NoButton) {
|
||||
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;
|
||||
case mouse_button::button2:
|
||||
case mouse_button::button3:
|
||||
// Nothing to do.
|
||||
cur.undispatched();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (geometry() == NoButton)
|
||||
InsetText::doDispatch(cur, cmd);
|
||||
else if (geometry() != ButtonOnly
|
||||
&& !hitButton(cmd))
|
||||
if (geometry() == NoButton
|
||||
|| (geometry() != ButtonOnly && !hitButton(cmd)))
|
||||
InsetText::doDispatch(cur, cmd);
|
||||
else
|
||||
cur.undispatched();
|
||||
@ -530,26 +534,6 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
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) {
|
||||
// The mouse click has to be within the inset!
|
||||
InsetText::doDispatch(cur, cmd);
|
||||
|
@ -107,16 +107,6 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
Layout const layout = bp.documentClass().emptyLayout();
|
||||
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
||||
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: {
|
||||
// We need to bypass the fancy quotes in Text
|
||||
FuncRequest f(LFUN_SELF_INSERT, "\"");
|
||||
|
@ -471,7 +471,7 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (!cur.selection())
|
||||
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||
InsetExternalMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
|
@ -146,17 +146,6 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
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:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
|
@ -197,7 +197,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (!cur.selection())
|
||||
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||
InsetGraphicsMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
|
@ -214,14 +214,6 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
InsetListingsMailer(*this).updateDialog(&cur.bv());
|
||||
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:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
|
@ -132,7 +132,7 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (!cur.selection())
|
||||
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||
InsetSpaceMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
|
@ -3179,12 +3179,6 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
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:
|
||||
movePrevCell(cur);
|
||||
cur.selection() = false;
|
||||
|
@ -424,6 +424,11 @@ ParagraphList & InsetText::paragraphs()
|
||||
}
|
||||
|
||||
|
||||
//void InsetInclude::addToToc(ParConstIterator const & cpit) const
|
||||
//{
|
||||
//}
|
||||
|
||||
|
||||
void InsetText::updateLabels(ParIterator const & it)
|
||||
{
|
||||
ParIterator it2 = it;
|
||||
|
@ -62,7 +62,7 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (!cur.selection())
|
||||
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||
InsetVSpaceMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
|
||||
|
@ -74,15 +74,6 @@ void InsetWrap::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
InsetWrapMailer(*this).updateDialog(&cur.bv());
|
||||
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:
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user