// via the temp cursor. If the inset wishes to change the real
// cursor it has to do so explicitly by using
// cur.bv().cursor() = cur; (or similar)'
- DispatchResult res;
if (inset)
inset->dispatch(cur, cmd);
// Now dispatch to the temporary cursor. If the real cursor should
// be modified, the inset's dispatch has to do so explicitly.
- if (!res.dispatched())
- res = cur.dispatch(cmd);
+ if (!cur.result().dispatched())
+ cur.dispatch(cmd);
- if (res.dispatched()) {
+ if (cur.result().dispatched()) {
// Redraw if requested or necessary.
- if (fitCursor() || res.update())
+ if (fitCursor() || cur.result().update())
update();
}
+2004-08-13 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ Fix toggling of collapsable insets with the mouse (bug 1558)
+
+ * lyxfunc.C (dispatch): adapt to LCursor changes
+
+ * BufferView_pimpl.C (workAreaDispatch): adapt to LCursor changes;
+ make sure that dispatch is not invoked twice
+
+ * cursor.C (needsUpdate): new method
+ (dispatch): return void
+ (result): new method, to access the DispatchResult of the cursor.
+
2004-08-13 José Matos <jamatos@lyx.org>
* tabular.C (docbook): close empty tags in XML. Fix bug 1147.
2004-08-12 André Pönitz <poenitz@gmx.net>
* text3.C: take out the 'cursor right' form insertInset and only
- do it in those places when it is really needed. Fixes crash on C-m...
+ do it in those places when it is really needed. Fixes crash on
+ C-m...
2004-08-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
}
-DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
+void LCursor::dispatch(FuncRequest const & cmd0)
{
lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
if (empty())
- return DispatchResult();
+ return;
FuncRequest cmd = cmd0;
LCursor safe = *this;
operator=(safe);
disp_.dispatched(false);
}
+}
+
+
+DispatchResult LCursor::result() const
+{
return disp_;
}
}
+void LCursor::needsUpdate()
+{
+ disp_.update(true);
+}
+
+
void LCursor::noUpdate()
{
disp_.update(false);
}
+
+
explicit LCursor(BufferView & bv);
/// dispatch from innermost inset upwards
- DispatchResult dispatch(FuncRequest const & cmd);
+ void dispatch(FuncRequest const & cmd);
+ /// get the resut of the last dispatch
+ DispatchResult result() const;
/// are we willing to handle this event?
bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
void undispatched();
/// the event was already dispatched
void dispatched();
+ /// call update() when done
+ void needsUpdate();
/// don't call update() when done
void noUpdate();
+2004-08-13 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * insetcollapsable.C (priv_dispatch): on a mouse press event, do
+ not ask for an update if we did nothing; on a mouse release, make
+ sure that the cursor is moved to the right position; on a mouse
+ release, exit from the inset instead of invoking a
+ LFUN_FINISHED_RIGHT.
+
+ * insetbase.C (dispatch): before invoking dispatch, set cursor
+ result to dispatch=update=true.
+
2004-08-13 José Matos <jamatos@lyx.org>
* insetgraphics.C (docbook): close empty tags in XML. Fix bug 1147.
void InsetBase::dispatch(LCursor & cur, FuncRequest & cmd)
{
+ cur.needsUpdate();
+ cur.dispatched();
priv_dispatch(cur, cmd);
}
cur.push(*this);
//lyxerr << "InsetCollapsable: edit xy" << endl;
if (status_ == Collapsed) {
- setStatus(Open);
- // We are not calling editXY() because the row cache of the
- // inset might be invalid. 'Entering from the left' should be
- // ok, though.
- InsetText::edit(cur, true);
return this;
}
return InsetText::editXY(cur, x, y);
void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
- //lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
- // << " button y: " << button_dim.y2 << endl;
+// lyxerr << "InsetCollapsable::priv_dispatch (begin): cmd: " << cmd
+// << " button y: " << button_dim.y2
+// << " coll/inline/open: " << status_ << endl;
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
if (status_ == Inlined)
InsetText::priv_dispatch(cur, cmd);
else if (status_ == Open && !hitButton(cmd))
InsetText::priv_dispatch(cur, cmd);
+ else
+ cur.noUpdate();
break;
case LFUN_MOUSE_MOTION:
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
setStatus(Open);
edit(cur, true);
+ cur.bv().cursor() = cur;
break;
case Open: {
- FuncRequest cmd1 = cmd;
- if (hitButton(cmd1)) {
+ if (hitButton(cmd)) {
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
setStatus(Collapsed);
- cur.undispatched();
- cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+ leaveInset(cur, *this);
+ cur.bv().cursor() = cur;
} else {
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
InsetText::priv_dispatch(cur, cmd);
default: {
update = false;
- DispatchResult res = view()->cursor().dispatch(cmd);
- if (res.dispatched())
- update |= res.update();
+ view()->cursor().dispatch(cmd);
+ if (view()->cursor().result().dispatched())
+ update |= view()->cursor().result().update();
else
update |= view()->dispatch(cmd);