[LyX/2.4.x] Re-focus workarea after some outline context-menu actions (see #1624)

Juergen Spitzmueller spitz at lyx.org
Tue Sep 24 15:02:33 UTC 2024


commit 624fd5f4421e27b286d5fc17c24e53732b7bfcc1
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Sep 24 08:47:55 2024 +0200

    Re-focus workarea after some outline context-menu actions (see #1624)
    
    Thanks Pavel for the main idea
    
    (cherry picked from commit 126cbec5e7c7d73c2a9f20f74b5d478b4e166507)
---
 src/frontends/qt/TocWidget.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index dc9667ca17..c91a3b728c 100644
--- a/src/frontends/qt/TocWidget.cpp
+++ b/src/frontends/qt/TocWidget.cpp
@@ -214,6 +214,8 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
 
 	// Start an undo group.
 	cur.beginUndoGroup();
+	// re-focus the workarea after the action?
+	bool refocus_wa = false;
 
 	switch (cmd.action())
 	{
@@ -259,6 +261,7 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
 				: item.parIDs();
 		docstring const arg = (type.empty()) ? id : id + " " + type;
 		dispatch(FuncRequest(cmd, arg));
+		refocus_wa = true;
 		break;
 	}
 
@@ -269,12 +272,22 @@ void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
 		outline(cmd.action());
 		break;
 
+	case LFUN_LABEL_INSERT_AS_REFERENCE:
+		refocus_wa = true;
+	// fall through
 	default: {
 		FuncRequest tmpcmd(cmd);
 		if (inset)
 			inset->dispatch(cur, tmpcmd);
 	}
 	}
+	if (refocus_wa) {
+		QMainWindow * mw = static_cast<QMainWindow *>(&gui_view_);
+		if (mw) {
+			mw->activateWindow();
+			mw->setFocus();
+		}
+	}
 	cur.endUndoGroup();
 }
 


More information about the lyx-cvs mailing list