* inset/InsetTabular.cpp (doDispatch): LFUN_MOUSE_PRESS: let Text::dispatch

do the work, unless we really have a reason not to (fixes bug 4133)

	* mathed/InsetMathNest.cpp (lfunMousePress): refactor the code to use
	BufferView::mouseSetCursor.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19507 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2007-08-13 15:44:19 +00:00
parent 5be5543d2c
commit e7b3dd74b5
3 changed files with 28 additions and 49 deletions

View File

@ -3204,39 +3204,17 @@ void InsetTabular::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_MOUSE_PRESS: case LFUN_MOUSE_PRESS:
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl; //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
// FIXME: the following should be replaced by a better fix
// that is already used for plain text (Text3.cpp).
cap::saveSelection(bvcur);
if (cmd.button() == mouse_button::button1 // do not reset cursor/selection if we have selected
|| (cmd.button() == mouse_button::button3 // some cells (bug 2715).
&& (&bvcur.selBegin().inset() != this || !tablemode(bvcur)))) { if (cmd.button() == mouse_button::button3
if (!bvcur.selection() && !cur.bv().mouseSetCursor(cur)) && &bvcur.selBegin().inset() == this
cur.noUpdate(); && tablemode(bvcur))
cur.selection() = false; ;
setCursorFromCoordinates(cur, cmd.x, cmd.y); else
cur.bv().mouseSetCursor(cur); // Let InsetText do it
break; cell(cur.idx())->dispatch(cur, cmd);
}
if (cmd.button() == mouse_button::button2) {
if (cap::selection()) {
// See comment in Text::dispatch why we
// do this
// FIXME This does not use paste_tabular,
// another reason why paste_tabular should go.
cap::copySelectionToStack();
cmd = FuncRequest(LFUN_PASTE, "0");
} else {
cmd = FuncRequest(LFUN_PRIMARY_SELECTION_PASTE,
"paragraph");
}
doDispatch(cur, cmd);
cur.bv().buffer()->markDirty();
cur.bv().mouseSetCursor(cur);
}
break; break;
case LFUN_MOUSE_MOTION: case LFUN_MOUSE_MOTION:
//lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl; //lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
if (cmd.button() == mouse_button::button1) { if (cmd.button() == mouse_button::button1) {

View File

@ -1153,32 +1153,30 @@ void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd)
{ {
//lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl; //lyxerr << "## lfunMousePress: buttons: " << cmd.button() << endl;
BufferView & bv = cur.bv(); BufferView & bv = cur.bv();
// FIXME: the following should be replaced by a better fix bv.mouseSetCursor(cur);
// that is already used for plain text (Text3.cpp).
cap::saveSelection(bv.cursor());
if (cmd.button() == mouse_button::button1) { if (cmd.button() == mouse_button::button1) {
//lyxerr << "## lfunMousePress: setting cursor to: " << cur << endl; //lyxerr << "## lfunMousePress: setting cursor to: " << cur << endl;
bv.mouseSetCursor(cur);
// Update the cursor update flags as needed: // Update the cursor update flags as needed:
// //
// Update::Decoration: tells to update the decoration (visual box // Update::Decoration: tells to update the decoration
// corners that define the inset)/ // (visual box corners that define
// Update::FitCursor: adjust the screen to the cursor position if // the inset)/
// needed // Update::FitCursor: adjust the screen to the cursor
// position if needed
// cur.result().update(): don't overwrite previously set flags. // cur.result().update(): don't overwrite previously set flags.
cur.updateFlags(Update::Decoration | Update::FitCursor | cur.result().update()); cur.updateFlags(Update::Decoration | Update::FitCursor
| cur.result().update());
} else if (cmd.button() == mouse_button::button2) { } else if (cmd.button() == mouse_button::button2) {
MathData ar;
if (cap::selection()) { if (cap::selection()) {
// See comment in Text::dispatch why we do this // See comment in Text::dispatch why we do this
cap::copySelectionToStack(); cap::copySelectionToStack();
cmd = FuncRequest(LFUN_PASTE, "0"); cmd = FuncRequest(LFUN_PASTE, "0");
doDispatch(cur, cmd); doDispatch(bv.cursor(), cmd);
} else } else {
MathData ar;
asArray(theSelection().get(), ar); asArray(theSelection().get(), ar);
bv.cursor().insert(ar);
cur.insert(ar); }
bv.mouseSetCursor(cur);
} }
} }

View File

@ -27,14 +27,14 @@ What's new
all of its menus and for help files. Documents strings like all of its menus and for help files. Documents strings like
"Chapter" are correctly translated on screen too. "Chapter" are correctly translated on screen too.
- Add support for translating the menus in Simplified Chinese. - Add support for translating the menus in Simplified Chinese.
* USER INTERFACE * USER INTERFACE
- Add "Save all" menu entry, to save all modified files (Bug 2840) - Add "Save all" menu entry, to save all modified files (Bug 2840).
- Mark modified files in the View menu with an asterisk (Bug 2876) - Mark modified files in the View menu with an asterisk (Bug 2876).
** Bug fixes: ** Bug fixes:
@ -47,6 +47,9 @@ What's new
* USER INTERFACE: * USER INTERFACE:
- Fix crash when clickin in a tabular cell and the "delete empty paragraph"
mechanism triggers (bug 4133).
- Fix loading non-lyx child documents with relative path names, change - Fix loading non-lyx child documents with relative path names, change
'Load' to 'Edit' in the child document dialog (Bugs 4107 and 4111) 'Load' to 'Edit' in the child document dialog (Bugs 4107 and 4111)