mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
bugfix (clicking into insets in insets was broken)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5140 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
47df264732
commit
fe61081acf
@ -11,8 +11,8 @@
|
|||||||
// The pristine updatable inset: Text
|
// The pristine updatable inset: Text
|
||||||
|
|
||||||
|
|
||||||
#ifndef InsetFootlike_H
|
#ifndef INSETFOOTLIKE_H
|
||||||
#define InsetFootlike_H
|
#define INSETFOOTLIKE_H
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
|
@ -1177,6 +1177,19 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd)
|
|||||||
Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
|
Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
|
||||||
{
|
{
|
||||||
BufferView * bv = ev.view();
|
BufferView * bv = ev.view();
|
||||||
|
switch (ev.action) {
|
||||||
|
case LFUN_MOUSE_PRESS:
|
||||||
|
lfunMousePress(ev);
|
||||||
|
return DISPATCHED;
|
||||||
|
case LFUN_MOUSE_MOTION:
|
||||||
|
lfunMouseMotion(ev);
|
||||||
|
return DISPATCHED;
|
||||||
|
case LFUN_MOUSE_RELEASE:
|
||||||
|
return lfunMouseRelease(ev) ? DISPATCHED : UNDISPATCHED;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bool was_empty = (paragraphs.begin()->empty() && !paragraphs.begin()->next());
|
bool was_empty = (paragraphs.begin()->empty() && !paragraphs.begin()->next());
|
||||||
no_selection = false;
|
no_selection = false;
|
||||||
RESULT result = UpdatableInset::localDispatch(ev);
|
RESULT result = UpdatableInset::localDispatch(ev);
|
||||||
@ -1241,17 +1254,6 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
|
|||||||
int updflag = false;
|
int updflag = false;
|
||||||
switch (ev.action) {
|
switch (ev.action) {
|
||||||
|
|
||||||
case LFUN_MOUSE_PRESS:
|
|
||||||
lfunMousePress(ev);
|
|
||||||
return DISPATCHED;
|
|
||||||
|
|
||||||
case LFUN_MOUSE_MOTION:
|
|
||||||
lfunMouseMotion(ev);
|
|
||||||
return DISPATCHED;
|
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
|
||||||
return lfunMouseRelease(ev) ? DISPATCHED : UNDISPATCHED;
|
|
||||||
|
|
||||||
// Normal chars
|
// Normal chars
|
||||||
case LFUN_SELFINSERT:
|
case LFUN_SELFINSERT:
|
||||||
if (bv->buffer()->isReadonly()) {
|
if (bv->buffer()->isReadonly()) {
|
||||||
|
51
src/text3.C
51
src/text3.C
@ -91,11 +91,11 @@ namespace {
|
|||||||
// check if the given co-ordinates are inside an inset at the
|
// check if the given co-ordinates are inside an inset at the
|
||||||
// given cursor, if one exists. If so, the inset is returned,
|
// given cursor, if one exists. If so, the inset is returned,
|
||||||
// and the co-ordinates are made relative. Otherwise, 0 is returned.
|
// and the co-ordinates are made relative. Otherwise, 0 is returned.
|
||||||
Inset * checkInset(BufferView * bv, LyXText const & text, int & x, int & y)
|
Inset * checkInset(BufferView * bv, LyXText const & text,
|
||||||
|
LyXCursor const & cur, int & x, int & y)
|
||||||
{
|
{
|
||||||
LyXCursor const & cursor = text.cursor;
|
lyx::pos_type const pos = cur.pos();
|
||||||
lyx::pos_type const pos = cursor.pos();
|
Paragraph /*const*/ & par = *cur.par();
|
||||||
Paragraph /*const*/ & par = *cursor.par();
|
|
||||||
|
|
||||||
if (pos >= par.size() || !par.isInset(pos))
|
if (pos >= par.size() || !par.isInset(pos))
|
||||||
return 0;
|
return 0;
|
||||||
@ -112,13 +112,14 @@ namespace {
|
|||||||
|
|
||||||
int const width = inset->width(bv, font);
|
int const width = inset->width(bv, font);
|
||||||
int const inset_x = font.isVisibleRightToLeft()
|
int const inset_x = font.isVisibleRightToLeft()
|
||||||
? (cursor.ix() - width) : cursor.ix();
|
? (cur.ix() - width) : cur.ix();
|
||||||
|
|
||||||
Box b(
|
Box b(
|
||||||
inset_x + inset->scroll(),
|
inset_x + inset->scroll(),
|
||||||
inset_x + width,
|
inset_x + width,
|
||||||
cursor.iy() - inset->ascent(bv, font),
|
cur.iy() - inset->ascent(bv, font),
|
||||||
cursor.iy() + inset->descent(bv, font));
|
cur.iy() + inset->descent(bv, font)
|
||||||
|
);
|
||||||
|
|
||||||
if (!b.contained(x, y)) {
|
if (!b.contained(x, y)) {
|
||||||
lyxerr[Debug::GUI] << "Missed inset at x,y " << x << "," << y
|
lyxerr[Debug::GUI] << "Missed inset at x,y " << x << "," << y
|
||||||
@ -142,23 +143,23 @@ Inset * LyXText::checkInsetHit(BufferView * bv, int & x, int & y) const
|
|||||||
{
|
{
|
||||||
int y_tmp = y + first_y;
|
int y_tmp = y + first_y;
|
||||||
|
|
||||||
LyXCursor cursor;
|
LyXCursor cur;
|
||||||
setCursorFromCoordinates(bv, cursor, x, y_tmp);
|
setCursorFromCoordinates(bv, cur, x, y_tmp);
|
||||||
|
|
||||||
Inset * inset = checkInset(bv, *this, x, y_tmp);
|
Inset * inset = checkInset(bv, *this, cur, x, y_tmp);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
y = y_tmp;
|
y = y_tmp;
|
||||||
return inset;
|
return inset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// look at previous position
|
// look at previous position
|
||||||
if (cursor.pos() == 0)
|
if (cur.pos() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// move back one
|
// move back one
|
||||||
setCursor(bv, cursor, cursor.par(), cursor.pos() - 1, true);
|
setCursor(bv, cur, cur.par(), cur.pos() - 1, true);
|
||||||
|
|
||||||
inset = checkInset(bv, *this, x, y_tmp);
|
inset = checkInset(bv, *this, cur, x, y_tmp);
|
||||||
if (inset)
|
if (inset)
|
||||||
y = y_tmp;
|
y = y_tmp;
|
||||||
return inset;
|
return inset;
|
||||||
@ -1277,8 +1278,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
? cursor.ix() - width : cursor.ix();
|
? cursor.ix() - width : cursor.ix();
|
||||||
int start_x = inset_x + tli->scroll();
|
int start_x = inset_x + tli->scroll();
|
||||||
FuncRequest cmd1 = cmd;
|
FuncRequest cmd1 = cmd;
|
||||||
cmd1.x -= start_x;
|
cmd1.x = cmd.x - start_x;
|
||||||
cmd1.y -= cursor.iy() + bv->text->first_y;
|
cmd1.y = cmd.y - cursor.iy() + bv->text->first_y;
|
||||||
tli->localDispatch(cmd1);
|
tli->localDispatch(cmd1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1363,8 +1364,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
// Check whether the inset was hit. If not reset mode,
|
// Check whether the inset was hit. If not reset mode,
|
||||||
// otherwise give the event to the inset
|
// otherwise give the event to the inset
|
||||||
if (inset_hit == bv->theLockingInset()) {
|
if (inset_hit == bv->theLockingInset()) {
|
||||||
FuncRequest cmd(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());
|
FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());
|
||||||
bv->theLockingInset()->localDispatch(cmd);
|
bv->theLockingInset()->localDispatch(cmd1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bv->unlockInset(bv->theLockingInset());
|
bv->unlockInset(bv->theLockingInset());
|
||||||
@ -1393,8 +1394,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
// we don't need the edit() call here! (Jug20020329)
|
// we don't need the edit() call here! (Jug20020329)
|
||||||
if (!bv->lockInset(inset))
|
if (!bv->lockInset(inset))
|
||||||
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
||||||
FuncRequest cmd(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());
|
FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());
|
||||||
inset->localDispatch(cmd);
|
inset->localDispatch(cmd1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// I'm not sure we should continue here if we hit an inset (Jug20020403)
|
// I'm not sure we should continue here if we hit an inset (Jug20020403)
|
||||||
@ -1451,8 +1452,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
// LyX does a kind of work-area grabbing for insets.
|
// LyX does a kind of work-area grabbing for insets.
|
||||||
// Only a ButtonPress FuncRequest outside the inset will
|
// Only a ButtonPress FuncRequest outside the inset will
|
||||||
// force a insetUnlock.
|
// force a insetUnlock.
|
||||||
FuncRequest cmd(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
|
FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
|
||||||
bv->theLockingInset()->localDispatch(cmd);
|
bv->theLockingInset()->localDispatch(cmd1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1511,11 +1512,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
if (isHighlyEditableInset(inset_hit)) {
|
if (isHighlyEditableInset(inset_hit)) {
|
||||||
// Highly editable inset, like math
|
// Highly editable inset, like math
|
||||||
UpdatableInset * inset = (UpdatableInset *) inset_hit;
|
UpdatableInset * inset = (UpdatableInset *) inset_hit;
|
||||||
FuncRequest cmd(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
|
FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
|
||||||
inset->localDispatch(cmd);
|
inset->localDispatch(cmd1);
|
||||||
} else {
|
} else {
|
||||||
FuncRequest cmd(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
|
FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button());
|
||||||
inset_hit->localDispatch(cmd);
|
inset_hit->localDispatch(cmd1);
|
||||||
// IMO this is a grosshack! Inset's should be changed so that
|
// IMO this is a grosshack! Inset's should be changed so that
|
||||||
// they call the actions they have to do with the insetButtonRel.
|
// they call the actions they have to do with the insetButtonRel.
|
||||||
// function and not in the edit(). This should be changed
|
// function and not in the edit(). This should be changed
|
||||||
|
Loading…
Reference in New Issue
Block a user