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;
}
int const screen_first = bv_->text->first_y;
if (bv_->theLockingInset()) {
// We are in inset locking mode
@ -626,8 +628,6 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
selection_possible = true;
screen_->hideCursor();
int const screen_first = bv_->text->first_y;
// Clear the selection
screen_->toggleSelection(bv_->text, bv_);
bv_->text->clearSelection();
@ -642,9 +642,12 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
selection_possible = false;
owner_->updateLayoutChoice();
owner_->message(inset->editMessage());
// IMO the inset has to be first in edit-mode and then we send the
// button press. (Jug 20020222)
inset->edit(bv_); //, xpos, ypos, button);
//inset->edit(bv_, xpos, ypos, button);
// We just have to lock the inset before calling a PressEvent on it!
// 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);
return;
}
@ -875,6 +878,10 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
inset->insetButtonRelease(bv_, x, y, button);
} else {
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);
}
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>
* 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>
* insetfloatlist.C (getScreenLabel): translate the GUI label.

View File

@ -187,7 +187,7 @@ void InsetText::init(InsetText const * ins, bool same_id)
insetDescent = 0;
insetWidth = 0;
old_max_width = 0;
no_selection = false;
no_selection = true;
need_update = FULL;
drawTextXOffset = 0;
drawTextYOffset = 0;
@ -750,7 +750,7 @@ void InsetText::insetUnlock(BufferView * bv)
the_locking_inset = 0;
}
hideInsetCursor(bv);
no_selection = false;
no_selection = true;
locked = false;
int code;
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)
{
no_selection = true;
no_selection = false;
// use this to check mouse motion for selection!
mouse_x = x;
@ -935,7 +935,6 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
x - inset_x,
y - inset_y,
button);
no_selection = false;
return;
} else if (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);
if (the_locking_inset)
updateLocal(bv, CURSOR, false);
no_selection = false;
return;
}
// otherwise only unlock the_locking_inset
the_locking_inset->insetUnlock(bv);
the_locking_inset = 0;
}
if (inset)
no_selection = true;
if (bv->theLockingInset()) {
if (isHighlyEditableInset(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);
if (the_locking_inset)
updateLocal(bv, CURSOR, false);
no_selection = false;
return;
}
}
@ -984,6 +984,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
lt = getLyXText(bv);
clear = true;
}
int old_first_y = lt->first_y;
lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent);
@ -1003,6 +1004,9 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
updateLocal(bv, CURSOR, false);
}
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);
// Insert primary selection with middle mouse
// 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();
}
showInsetCursor(bv);
no_selection = false;
}
bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
{
no_selection = true;
if (the_locking_inset) {
return the_locking_inset->insetButtonRelease(bv,
x - inset_x, y - inset_y,