Do not reset custom space values if accessed via context menu (#8847)

This commit is contained in:
Juergen Spitzmueller 2013-11-15 19:41:36 +01:00
parent c89ae3b517
commit 7e259c8d76
3 changed files with 23 additions and 7 deletions

View File

@ -231,7 +231,7 @@ Menuset
Item "Horizontal Fill (Right Arrow)|g" "inset-modify space \rightarrowfill{}"
Item "Horizontal Fill (Up Brace)|p" "inset-modify space \upbracefill{}"
Item "Horizontal Fill (Down Brace)|B" "inset-modify space \downbracefill{}"
Item "Custom Length|C" "command-sequence inset-modify space \hspace{} \length 1in; inset-settings"
Item "Custom Length|C" "command-sequence inset-modify space \hspace{}; inset-settings"
Separator
Item "Settings...|S" "inset-settings"
End
@ -263,7 +263,7 @@ Menuset
Item "MedSkip|M" "inset-modify vspace medskip"
Item "BigSkip|B" "inset-modify vspace bigskip"
Item "VFill|F" "inset-modify vspace vfill"
Item "Custom|C" "command-sequence inset-modify vspace 1in; inset-settings"
Item "Custom|C" "command-sequence inset-modify vspace custom; inset-settings"
Separator
Item "Settings...|e" "inset-settings"
End

View File

@ -146,10 +146,16 @@ void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
case LFUN_INSET_MODIFY: {
cur.recordUndo();
string2params(to_utf8(cmd.argument()), params_);
string arg = to_utf8(cmd.argument());
if (arg == "space \\hspace{}")
arg += params_.length.len().empty()
? " \\length 1" + string(stringFromUnit(Length::defaultUnit()))
: " \\length " + params_.length.asString();
string2params(arg, params_);
break;
}
case LFUN_INSET_DIALOG_UPDATE:
cur.bv().updateDialog("space", params2string(params()));
@ -172,7 +178,7 @@ bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
InsetSpaceParams params;
string2params(to_utf8(cmd.argument()), params);
status.setOnOff(params_.kind == params.kind);
status.setEnabled(true);
status.setEnabled(true);
} else
status.setEnabled(false);
return true;

View File

@ -59,7 +59,12 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INSET_MODIFY: {
cur.recordUndo();
InsetVSpace::string2params(to_utf8(cmd.argument()), space_);
string arg = to_utf8(cmd.argument());
if (arg == "vspace custom")
arg = (space_.kind() == VSpace::LENGTH)
? "vspace " + space_.length().asString()
: "vspace 1" + string(stringFromUnit(Length::defaultUnit()));
InsetVSpace::string2params(arg, space_);
break;
}
@ -78,7 +83,12 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "vspace") {
VSpace vspace;
InsetVSpace::string2params(to_utf8(cmd.argument()), vspace);
string arg = to_utf8(cmd.argument());
if (arg == "vspace custom")
arg = (space_.kind() == VSpace::LENGTH)
? "vspace " + space_.length().asString()
: "vspace 1" + string(stringFromUnit(Length::defaultUnit()));
InsetVSpace::string2params(arg, vspace);
status.setOnOff(vspace == space_);
}
status.setEnabled(true);