End
#
-# InsetTocLabel context menu
+# Toc Labels and References context menu
#
Menu "context-toc-label"
Item "Copy Label as Reference|C" "copy-label-as-reference"
+ Item "Insert Reference at Cursor Position|I" "insert-label-as-reference"
End
End
LFUN_TAB_DELETE,
LFUN_WORD_FINDADV, // Tommaso, 20081003
LFUN_REGEXP_MODE, // Tommaso, 20081003
- LFUN_COPY_LABEL_AS_REF, // sts, 20081116
- // 320
LFUN_VC_COMMAND,
- LFUN_MATH_FONT_STYLE,
+ // 320
+ LFUN_COPY_LABEL_AS_REF, // sts, 20081116
+ LFUN_INSERT_LABEL_AS_REF, // vfr, 20090407
LFUN_PHANTOM_INSERT, // uwestoehr, 20090130
LFUN_INSET_BEGIN, // JMarc, 20090316
LFUN_INSET_END, // JMarc, 20090316
LFUN_BUFFER_ZOOM_OUT, // vfr, 20090330
// 330
LFUN_MATH_BIGDELIM,
+ LFUN_MATH_FONT_STYLE,
LFUN_LASTACTION // end of the table
*/
{ LFUN_COPY_LABEL_AS_REF, "copy-label-as-reference", ReadOnly | NoUpdate, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_INSERT_LABEL_AS_REF
+ * \li Action: Inserts the label as a cross-reference at the position of the cursor.
+ * \li Syntax: insert-label-as-reference
+ * \li Origin: vfr, 7 Apr 2009
+ * \endvar
+ */
+ { LFUN_INSERT_LABEL_AS_REF, "insert-label-as-reference", Noop, Edit},
+
/*!
* \var lyx::FuncCode lyx::LFUN_BUFFER_ZOOM_IN
* \li Action: Increases the zoom of the screen fonts.
void TocWidget::doDispatch(Cursor const & cur, FuncRequest const & cmd)
{
switch(cmd.action) {
- case LFUN_COPY_LABEL_AS_REF: {
+
+ case LFUN_COPY_LABEL_AS_REF:
+ case LFUN_INSERT_LABEL_AS_REF: {
QModelIndex index = tocTV->currentIndex();
- TocItem const & item =
+ TocItem const & item =
gui_view_.tocModels().currentItem(current_type_, index);
if (!item.str().empty()) {
InsetCommandParams p(REF_CODE, "ref");
p["reference"] = item.str();
- cap::clearSelection();
- cap::copyInset(cur, new InsetRef(*cur.buffer(), p), item.str());
+ if (cmd.action == LFUN_COPY_LABEL_AS_REF) {
+ cap::clearSelection();
+ cap::copyInset(cur, new InsetRef(*cur.buffer(), p), item.str());
+ } else {
+ string const data = InsetCommand::params2string("ref", p);
+ dispatch(FuncRequest(LFUN_INSET_INSERT, data));
+ }
}
break;
}