Fixes to mouse handling in and outside a InsetText (fix #308, #309).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3863 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-03-29 12:24:50 +00:00
parent 0cdd30b8f8
commit b45d1b31f5
4 changed files with 37 additions and 12 deletions

View File

@ -608,6 +608,8 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
paste_internally = true; paste_internally = true;
} }
int const screen_first = bv_->text->first_y;
if (bv_->theLockingInset()) { if (bv_->theLockingInset()) {
// We are in inset locking mode // We are in inset locking mode
@ -626,8 +628,6 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
selection_possible = true; selection_possible = true;
screen_->hideCursor(); screen_->hideCursor();
int const screen_first = bv_->text->first_y;
// Clear the selection // Clear the selection
screen_->toggleSelection(bv_->text, bv_); screen_->toggleSelection(bv_->text, bv_);
bv_->text->clearSelection(); bv_->text->clearSelection();
@ -642,9 +642,12 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
selection_possible = false; selection_possible = false;
owner_->updateLayoutChoice(); owner_->updateLayoutChoice();
owner_->message(inset->editMessage()); owner_->message(inset->editMessage());
// IMO the inset has to be first in edit-mode and then we send the //inset->edit(bv_, xpos, ypos, button);
// button press. (Jug 20020222) // We just have to lock the inset before calling a PressEvent on it!
inset->edit(bv_); //, xpos, ypos, button); // we don't need the edit() call here! (Jug20020329)
if (!bv_->lockInset(inset)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
}
inset->insetButtonPress(bv_, xpos, ypos, button); inset->insetButtonPress(bv_, xpos, ypos, button);
return; return;
} }
@ -875,6 +878,10 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
inset->insetButtonRelease(bv_, x, y, button); inset->insetButtonRelease(bv_, x, y, button);
} else { } else {
inset_hit->insetButtonRelease(bv_, x, y, button); inset_hit->insetButtonRelease(bv_, x, y, button);
// IMO this is a grosshack! Inset's should be changed so that
// they call the actions they have to do with the insetButtonRel.
// function and not in the edit(). This should be changed
// (Jug 20020329)
inset_hit->edit(bv_, x, y, button); inset_hit->edit(bv_, x, y, button);
} }
return; return;

View File

@ -1,3 +1,11 @@
2002-03-29 Juergen Vigna <jug@sad.it>
* BufferView_pimpl.C (workAreaButtonPress): just lock the inset don't
call the edit() as it is not needed (and wrong) IMO.
(workAreaButtonPress): set the screen_first variable before evt.
unlock the inset as this may change screen_first and then we have
a wrong y position for the click!
2002-03-28 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-03-28 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* MenuBackend.C (expand): another translation that I missed * MenuBackend.C (expand): another translation that I missed

View File

@ -1,3 +1,9 @@
2002-03-29 Juergen Vigna <jug@sad.it>
* insettext.C (insetButtonPress): change behaviour of no_selection
to the one in the BufferView selection_possible and fix the spurious
selection bug with it.
2002-03-28 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-03-28 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insetfloatlist.C (getScreenLabel): translate the GUI label. * insetfloatlist.C (getScreenLabel): translate the GUI label.

View File

@ -187,7 +187,7 @@ void InsetText::init(InsetText const * ins, bool same_id)
insetDescent = 0; insetDescent = 0;
insetWidth = 0; insetWidth = 0;
old_max_width = 0; old_max_width = 0;
no_selection = false; no_selection = true;
need_update = FULL; need_update = FULL;
drawTextXOffset = 0; drawTextXOffset = 0;
drawTextYOffset = 0; drawTextYOffset = 0;
@ -750,7 +750,7 @@ void InsetText::insetUnlock(BufferView * bv)
the_locking_inset = 0; the_locking_inset = 0;
} }
hideInsetCursor(bv); hideInsetCursor(bv);
no_selection = false; no_selection = true;
locked = false; locked = false;
int code; int code;
if (drawFrame_ == LOCKED) if (drawFrame_ == LOCKED)
@ -918,7 +918,7 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
{ {
no_selection = true; no_selection = false;
// use this to check mouse motion for selection! // use this to check mouse motion for selection!
mouse_x = x; mouse_x = x;
@ -935,7 +935,6 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
x - inset_x, x - inset_x,
y - inset_y, y - inset_y,
button); button);
no_selection = false;
return; return;
} else if (inset) { } else if (inset) {
// otherwise unlock the_locking_inset and lock the new inset // otherwise unlock the_locking_inset and lock the new inset
@ -948,13 +947,15 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
// inset->edit(bv, x - inset_x, y - inset_y, button); // inset->edit(bv, x - inset_x, y - inset_y, button);
if (the_locking_inset) if (the_locking_inset)
updateLocal(bv, CURSOR, false); updateLocal(bv, CURSOR, false);
no_selection = false;
return; return;
} }
// otherwise only unlock the_locking_inset // otherwise only unlock the_locking_inset
the_locking_inset->insetUnlock(bv); the_locking_inset->insetUnlock(bv);
the_locking_inset = 0; the_locking_inset = 0;
} }
if (inset)
no_selection = true;
if (bv->theLockingInset()) { if (bv->theLockingInset()) {
if (isHighlyEditableInset(inset)) { if (isHighlyEditableInset(inset)) {
UpdatableInset * uinset = static_cast<UpdatableInset*>(inset); UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
@ -969,7 +970,6 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
uinset->edit(bv, x - inset_x, y - inset_y, 0); uinset->edit(bv, x - inset_x, y - inset_y, 0);
if (the_locking_inset) if (the_locking_inset)
updateLocal(bv, CURSOR, false); updateLocal(bv, CURSOR, false);
no_selection = false;
return; return;
} }
} }
@ -984,6 +984,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
lt = getLyXText(bv); lt = getLyXText(bv);
clear = true; clear = true;
} }
int old_first_y = lt->first_y;
lt->setCursorFromCoordinates(bv, x - drawTextXOffset, lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent); y + insetAscent);
@ -1003,6 +1004,9 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
updateLocal(bv, CURSOR, false); updateLocal(bv, CURSOR, false);
} }
bv->owner()->setLayout(cpar(bv)->layout()); bv->owner()->setLayout(cpar(bv)->layout());
// we moved the view we cannot do mouse selection in this case!
if (getLyXText(bv)->first_y != old_first_y)
no_selection = true;
old_par = cpar(bv); old_par = cpar(bv);
// Insert primary selection with middle mouse // Insert primary selection with middle mouse
// if there is a local selection in the current buffer, // if there is a local selection in the current buffer,
@ -1018,12 +1022,12 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
getLyXText(bv)->clearSelection(); getLyXText(bv)->clearSelection();
} }
showInsetCursor(bv); showInsetCursor(bv);
no_selection = false;
} }
bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
{ {
no_selection = true;
if (the_locking_inset) { if (the_locking_inset) {
return the_locking_inset->insetButtonRelease(bv, return the_locking_inset->insetButtonRelease(bv,
x - inset_x, y - inset_y, x - inset_x, y - inset_y,