Context menu for collapsing minimalistic insets such as ERT.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23880 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-03-21 18:02:47 +00:00
parent b922cfd3b3
commit de6f93296f
2 changed files with 19 additions and 7 deletions

View File

@ -556,6 +556,14 @@ Menuset
Item "Go back to Reference|G" "bookmark-goto 0"
End
#
# InsetCollapsable context menu
#
Menu "context-collapsable"
Item "Open Inset|O" "inset-toggle open"
Item "Close Inset|C" "inset-toggle close"
End
#
# Edit context menu
#

View File

@ -748,8 +748,9 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
return InsetText::getStatus(cur, cmd, flag);
case LFUN_INSET_TOGGLE:
if (cmd.argument() == "open" || cmd.argument() == "close" ||
cmd.argument() == "toggle")
if ((cmd.argument() == "open" && status_ == Open)
|| (cmd.argument() == "close" && status_ != Open)
|| cmd.argument() == "toggle")
flag.enabled(true);
else
flag.enabled(false);
@ -882,11 +883,14 @@ bool InsetCollapsable::undefined() const
docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
int y) const
{
if (geometry() != NoButton) {
Dimension dim = dimensionCollapsed();
if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
return docstring();
}
if (geometry() == NoButton)
return from_ascii("context-collapsable");
Dimension dim = dimensionCollapsed();
if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
//FIXME: We should offer the "context-collapsable" menu here too but
// this is not possible right now because the cursor must be set first.
return docstring();
return InsetText::contextMenu(bv, x, y);
}