- lyxerr << "InsetCollapsable::localDispatch: "
- << cmd.action << " '" << cmd.argument << "'\n";
- BufferView * bv = cmd.view();
- switch (cmd.action) {
- case LFUN_INSET_EDIT: {
- if (!cmd.argument.empty()) {
- UpdatableInset::localDispatch(cmd);
- if (collapsed_) {
- lyxerr << "branch collapsed_\n";
- collapsed_ = false;
- if (bv->lockInset(this)) {
- inset.setUpdateStatus(InsetText::FULL);
- bv->updateInset(this);
- bv->buffer()->markDirty();
- inset.localDispatch(cmd);
- first_after_edit = true;
- }
- } else {
- lyxerr << "branch not collapsed_\n";
- if (bv->lockInset(this))
- inset.localDispatch(cmd);
- }
- return DISPATCHED;
- }
-
-#ifdef WITH_WARNINGS
-#warning Fix this properly in BufferView_pimpl::workAreaButtonRelease
-#endif
- if (cmd.button() == mouse_button::button3)
- return DISPATCHED;
-
- UpdatableInset::localDispatch(cmd);
-
- if (collapsed_) {
- collapsed_ = false;
- // set this only here as it should be recollapsed only if
- // it was already collapsed!
- first_after_edit = true;
- if (!bv->lockInset(this))
- return DISPATCHED;
- bv->updateInset(this);
- bv->buffer()->markDirty();
- inset.localDispatch(cmd);
- } else {
- FuncRequest cmd1 = cmd;
- if (!bv->lockInset(this))
- return DISPATCHED;
- if (cmd.y <= button_bottom_y) {
- cmd1.y = 0;
- } else {
- cmd1.y = ascent() + cmd.y - (height_collapsed() + inset.ascent());
- }
- inset.localDispatch(cmd);
- }
- return DISPATCHED;
- }
-
- case LFUN_MOUSE_PRESS:
- if (!collapsed_ && cmd.y > button_bottom_y)
- inset.localDispatch(adjustCommand(cmd));
- return DISPATCHED;
-
- case LFUN_MOUSE_MOTION:
- if (!collapsed_ && cmd.y > button_bottom_y)
- inset.localDispatch(adjustCommand(cmd));
- return DISPATCHED;
-
- case LFUN_MOUSE_RELEASE:
- lfunMouseRelease(cmd);
- return DISPATCHED;
-
- default:
- UpdatableInset::RESULT result = inset.localDispatch(cmd);
- if (result >= FINISHED)
- bv->unlockInset(this);
- first_after_edit = false;
- return result;
- }