Author: sagamusix
Date: Sat Jun 29 00:27:03 2024
New Revision: 21097
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21097
Log:
[Fix] Properly restore keyboard focus in the upper half of the MDI views after OpenMPT regains focus (https://bugs.openmpt.org/view.php?id=1795).
Modified:
trunk/OpenMPT/mptrack/Globals.cpp
trunk/OpenMPT/mptrack/Globals.h
Modified: trunk/OpenMPT/mptrack/Globals.cpp
==============================================================================
--- trunk/OpenMPT/mptrack/Globals.cpp Fri Jun 28 22:05:47 2024 (r21096)
+++ trunk/OpenMPT/mptrack/Globals.cpp Sat Jun 29 00:27:03 2024 (r21097)
@@ -1,8 +1,9 @@
/*
- * globals.cpp
+ * Globals.cpp
* -----------
- * Purpose: Implementation of various views of the tracker interface.
- * Notes : (currently none)
+ * Purpose: Implementation of the base classes for the upper and lower half of the MDI child windows.
+ * Notes : CModControlDlg = Upper half (Ctrl_*.cpp/h), which is contained inside a CModControlView together with the tab switcher (CModTabCtrl).
+ * CModScrollView = Lower half (View_*.cpp/h).
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
@@ -189,10 +190,12 @@
//{{AFX_MSG_MAP(CModControlView)
ON_WM_SIZE()
ON_WM_DESTROY()
+ ON_WM_SETFOCUS()
ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL1, &CModControlView::OnTabSelchange)
ON_MESSAGE(WM_MOD_ACTIVATEVIEW, &CModControlView::OnActivateModView)
ON_MESSAGE(WM_MOD_CTRLMSG, &CModControlView::OnModCtrlMsg)
ON_MESSAGE(WM_MOD_GETTOOLTIPTEXT, &CModControlView::OnGetToolTipText)
+ ON_MESSAGE(WM_MOD_MDIDEACTIVATE, &CModControlView::OnSaveFocusItem)
ON_COMMAND(ID_EDIT_CUT, &CModControlView::OnEditCut)
ON_COMMAND(ID_EDIT_COPY, &CModControlView::OnEditCopy)
ON_COMMAND(ID_EDIT_PASTE, &CModControlView::OnEditPaste)
@@ -219,6 +222,22 @@
}
+LRESULT CModControlView::OnSaveFocusItem(WPARAM, LPARAM)
+{
+ // Ugly workaround for focus issue in upper view (https://bugs.openmpt.org/view.php?id=1795)
+ m_oldWnd = ::GetFocus();
+ return 0;
+}
+
+
+void CModControlView::OnSetFocus(CWnd* pOldWnd)
+{
+ if(m_oldWnd && ::IsChild(m_hWnd, m_oldWnd))
+ ::SetFocus(m_oldWnd);
+ CView::OnSetFocus(pOldWnd);
+}
+
+
void CModControlView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
Modified: trunk/OpenMPT/mptrack/Globals.h
==============================================================================
--- trunk/OpenMPT/mptrack/Globals.h Fri Jun 28 22:05:47 2024 (r21096)
+++ trunk/OpenMPT/mptrack/Globals.h Sat Jun 29 00:27:03 2024 (r21097)
@@ -1,7 +1,7 @@
/*
* Globals.h
* ---------
- * Purpose: Implementation of various views of the tracker interface.
+ * Purpose: Implementation of the base classes for the upper and lower half of the MDI child windows.
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
@@ -125,6 +125,7 @@
Page m_nActiveDlg = Page::Unknown;
int m_nInstrumentChanged = -1;
HWND m_hWndView = nullptr, m_hWndMDI = nullptr;
+ HWND m_oldWnd = nullptr;
protected: // create from serialization only
CModControlView() = default;
@@ -157,6 +158,8 @@
protected:
//{{AFX_MSG(CModControlView)
+ afx_msg LRESULT OnSaveFocusItem(WPARAM, LPARAM);
+ afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg void OnTabSelchange(NMHDR* pNMHDR, LRESULT* pResult);
|