mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 14:04:25 +00:00
We now register the coordinates where the latest mouse press happens,
and if that's on the inset button we are on when releasing,
we toggle the inset.
Thus, minimal unintentional mouse movements don't lead to the button not
to respond.
(cherry picked from commit effd65a586
)
This commit is contained in:
parent
6b4c7c5e91
commit
6ea4a67863
@ -176,6 +176,7 @@ LyXErr & operator<<(LyXErr & os, CursorData const & cur)
|
|||||||
Cursor::Cursor(BufferView & bv)
|
Cursor::Cursor(BufferView & bv)
|
||||||
: CursorData(&bv.buffer()), bv_(&bv),
|
: CursorData(&bv.buffer()), bv_(&bv),
|
||||||
x_target_(-1), textTargetOffset_(0),
|
x_target_(-1), textTargetOffset_(0),
|
||||||
|
x_clickpos_(-1), y_clickpos_(-1),
|
||||||
beforeDispatchPosX_(0), beforeDispatchPosY_(0)
|
beforeDispatchPosX_(0), beforeDispatchPosY_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -1093,6 +1094,13 @@ void Cursor::updateTextTargetOffset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Cursor::setClickPos(int x, int y)
|
||||||
|
{
|
||||||
|
x_clickpos_ = x;
|
||||||
|
y_clickpos_ = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::info(odocstream & os, bool devel_mode) const
|
void Cursor::info(odocstream & os, bool devel_mode) const
|
||||||
{
|
{
|
||||||
for (int i = 1, n = depth(); i < n; ++i) {
|
for (int i = 1, n = depth(); i < n; ++i) {
|
||||||
|
@ -288,6 +288,12 @@ public:
|
|||||||
void setTargetX();
|
void setTargetX();
|
||||||
/// clear targetX, i.e. set it to -1
|
/// clear targetX, i.e. set it to -1
|
||||||
void clearTargetX();
|
void clearTargetX();
|
||||||
|
/// return x position of latest mouse press or -1 if unset
|
||||||
|
int xClickPos() const { return x_clickpos_; }
|
||||||
|
/// return y position of latest mouse press or -1 if unset
|
||||||
|
int yClickPos() const { return y_clickpos_; }
|
||||||
|
/// register mouse press coordinates
|
||||||
|
void setClickPos(int x, int y);
|
||||||
/// set offset to actual position - targetX
|
/// set offset to actual position - targetX
|
||||||
void updateTextTargetOffset();
|
void updateTextTargetOffset();
|
||||||
/// distance between actual and targeted position during last up/down in text
|
/// distance between actual and targeted position during last up/down in text
|
||||||
@ -442,6 +448,9 @@ private:
|
|||||||
int x_target_;
|
int x_target_;
|
||||||
/// if a x_target cannot be hit exactly in a text, put the difference here
|
/// if a x_target cannot be hit exactly in a text, put the difference here
|
||||||
int textTargetOffset_;
|
int textTargetOffset_;
|
||||||
|
/// Exact position of mouse click
|
||||||
|
int x_clickpos_;
|
||||||
|
int y_clickpos_;
|
||||||
/// the start of the new born word
|
/// the start of the new born word
|
||||||
DocIterator new_word_;
|
DocIterator new_word_;
|
||||||
/// position before dispatch started
|
/// position before dispatch started
|
||||||
|
@ -1780,6 +1780,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
bvcur.setMark(false);
|
bvcur.setMark(false);
|
||||||
switch (cmd.button()) {
|
switch (cmd.button()) {
|
||||||
case mouse_button::button1:
|
case mouse_button::button1:
|
||||||
|
bvcur.setClickPos(cmd.x(), cmd.y());
|
||||||
if (!bvcur.selection())
|
if (!bvcur.selection())
|
||||||
// Set the cursor
|
// Set the cursor
|
||||||
bvcur.resetAnchor();
|
bvcur.resetAnchor();
|
||||||
@ -1868,6 +1869,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
switch (cmd.button()) {
|
switch (cmd.button()) {
|
||||||
case mouse_button::button1:
|
case mouse_button::button1:
|
||||||
|
// unregister last mouse press position
|
||||||
|
cur.bv().cursor().setClickPos(-1, -1);
|
||||||
// Cursor was set at LFUN_MOUSE_PRESS or LFUN_MOUSE_MOTION time.
|
// Cursor was set at LFUN_MOUSE_PRESS or LFUN_MOUSE_MOTION time.
|
||||||
// If there is a new selection, update persistent selection;
|
// If there is a new selection, update persistent selection;
|
||||||
// otherwise, single click does not clear persistent selection
|
// otherwise, single click does not clear persistent selection
|
||||||
|
@ -353,9 +353,13 @@ void Inset::doDispatch(Cursor & cur, FuncRequest &cmd)
|
|||||||
{
|
{
|
||||||
switch (cmd.action()) {
|
switch (cmd.action()) {
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
// if the derived inset did not explicitly handle mouse_release,
|
// If the derived inset did not explicitly handle mouse_release,
|
||||||
// we assume we request the settings dialog
|
// we assume we request the settings dialog,
|
||||||
if (!cur.selection() && cmd.button() == mouse_button::button1
|
// except if we are about to select (MOUSE_MOTION that started
|
||||||
|
// outside the inset).
|
||||||
|
if ((!cur.selection() || covers(cur.bv(), cur.bv().cursor().xClickPos(),
|
||||||
|
cur.bv().cursor().yClickPos()))
|
||||||
|
&& cmd.button() == mouse_button::button1
|
||||||
&& clickable(cur.bv(), cmd.x(), cmd.y()) && hasSettings()) {
|
&& clickable(cur.bv(), cmd.x(), cmd.y()) && hasSettings()) {
|
||||||
FuncRequest tmpcmd(LFUN_INSET_SETTINGS);
|
FuncRequest tmpcmd(LFUN_INSET_SETTINGS);
|
||||||
dispatch(cur, tmpcmd);
|
dispatch(cur, tmpcmd);
|
||||||
|
@ -445,6 +445,8 @@ docstring const InsetCollapsible::getNewLabel(docstring const & l) const
|
|||||||
void InsetCollapsible::edit(Cursor & cur, bool front, EntryDirection entry_from)
|
void InsetCollapsible::edit(Cursor & cur, bool front, EntryDirection entry_from)
|
||||||
{
|
{
|
||||||
//lyxerr << "InsetCollapsible: edit left/right" << endl;
|
//lyxerr << "InsetCollapsible: edit left/right" << endl;
|
||||||
|
// We might have a selection if we moved the mouse on the button only
|
||||||
|
cur.clearSelection();
|
||||||
cur.push(*this);
|
cur.push(*this);
|
||||||
InsetText::edit(cur, front, entry_from);
|
InsetText::edit(cur, front, entry_from);
|
||||||
}
|
}
|
||||||
@ -518,9 +520,11 @@ void InsetCollapsible::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
cur.noScreenUpdate();
|
cur.noScreenUpdate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if we are selecting, we do not want to
|
// If we are selecting, we do not want to toggle the inset
|
||||||
// toggle the inset.
|
// except if the selection started at the inset button we're still on.
|
||||||
if (cur.selection())
|
// The latter addresses #12820.
|
||||||
|
if (cur.selection() && !clickable(cur.bv(), cur.bv().cursor().xClickPos(),
|
||||||
|
cur.bv().cursor().yClickPos()))
|
||||||
break;
|
break;
|
||||||
// Left button is clicked, the user asks to
|
// Left button is clicked, the user asks to
|
||||||
// toggle the inset visual state.
|
// toggle the inset visual state.
|
||||||
|
@ -54,6 +54,9 @@ What's new
|
|||||||
|
|
||||||
- Avoid crashing on a recursive macro definition (bug 12633).
|
- Avoid crashing on a recursive macro definition (bug 12633).
|
||||||
|
|
||||||
|
- Fix several problems where insets did not react on click on
|
||||||
|
the Mac (bugs 12279, 12418, 12820).
|
||||||
|
|
||||||
- Fix issue with on-screen instant preview and the mathpazo package.
|
- Fix issue with on-screen instant preview and the mathpazo package.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user