Mercurial > octave
changeset 25220:07bddddc5856 stable
Restore Variable Editor focusWidget lost in dock/undock transition (bug #53410)
* variable-editor.cc (variable_editor::variable_editor): Initialize new member
variable m_variable_focus_widget to nullptr.
(variable_editor::focusInEvent): If the m_main window's focusWidget() is
nullptr, check if the recorded m_variable_focus_widget is still valid within
the m_main container. If so, use it as a valid pointer and restore its
focus.
(variable_editor::focusOutEvent): Record m_main's focusWidget() just prior
to transition to/from docked state.
* variable-editor.h (variable_editor:octave_dock_widget): A class member
variable m_variable_focus_widget to keep track of focusWidget().
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Tue, 10 Apr 2018 23:22:03 -0500 |
parents | 164399071f4d |
children | e1024058833c |
files | libgui/src/variable-editor.cc libgui/src/variable-editor.h |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/variable-editor.cc Wed Apr 11 15:13:10 2018 -0400 +++ b/libgui/src/variable-editor.cc Tue Apr 10 23:22:03 2018 -0500 @@ -990,7 +990,8 @@ m_sel_font (), m_table_colors (), m_current_focus_vname (""), - m_hovered_focus_vname ("") + m_hovered_focus_vname (""), + m_variable_focus_widget (nullptr) { setObjectName ("VariableEditor"); set_title (tr ("Variable Editor")); @@ -1038,10 +1039,20 @@ { octave_dock_widget::focusInEvent (ev); - // set focus to the current variable + // set focus to the current variable or most recent if still valid QWidget *fw = m_main->focusWidget (); if (fw != nullptr) fw->setFocus (); + else if (m_main->isAncestorOf (m_variable_focus_widget)) + m_variable_focus_widget->setFocus (); + } + + void variable_editor::focusOutEvent (QFocusEvent *ev) + { + // focusWidget() appears lost in transition to/from main window + m_variable_focus_widget = m_main->focusWidget (); + + octave_dock_widget::focusOutEvent (ev); } // Add an action to a menu or the widget itself.
--- a/libgui/src/variable-editor.h Wed Apr 11 15:13:10 2018 -0400 +++ b/libgui/src/variable-editor.h Tue Apr 10 23:22:03 2018 -0500 @@ -338,6 +338,8 @@ void focusInEvent (QFocusEvent *ev); + void focusOutEvent (QFocusEvent *ev); + private: QAction * add_action (QMenu *menu, const QIcon& icon, const QString& text, @@ -377,6 +379,8 @@ QString m_current_focus_vname; QString m_hovered_focus_vname; + + QWidget *m_variable_focus_widget; }; }