Author: dquintana
Date: Thu Apr 24 17:42:16 2014
New Revision: 62959
URL:
http://svn.reactos.org/svn/reactos?rev=62959&view=rev
Log:
[RSHELL]
* Implement selecting the first/last item, and make the menu system choose to select the
first item when opening a submenu with the keyboard.
Modified:
branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
branches/shell-experiments/base/shell/rshell/CMenuBand.h
branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp
branches/shell-experiments/base/shell/rshell/CMenuToolbars.h
Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] Thu Apr 24
17:42:16 2014
@@ -461,6 +461,18 @@
}
else if (nCmdID == 19) // popup-related
{
+ return S_FALSE;
+ }
+ else if (nCmdID == 5) // select an item
+ {
+ if (nCmdexecopt == 0) // first
+ {
+ _KeyboardItemChange(VK_HOME);
+ }
+ else if (nCmdexecopt == -2) // last
+ {
+ _KeyboardItemChange(VK_END);
+ }
return S_FALSE;
}
@@ -794,14 +806,14 @@
if (!tb)
{
// If no hot item was selected choose the appropriate toolbar
- if (change == VK_UP)
+ if (change == VK_UP || change == VK_END)
{
if (m_staticToolbar)
tb = m_staticToolbar;
else
tb = m_SFToolbar;
}
- else if (change == VK_DOWN)
+ else if (change == VK_DOWN || change == VK_HOME)
{
if (m_SFToolbar)
tb = m_SFToolbar;
@@ -882,7 +894,7 @@
return m_subMenuParent->OnSelect(MPOS_CANCELLEVEL);
case MPOS_SELECTRIGHT:
- if (m_hotBar && m_hotItem >= 0 &&
m_hotBar->PopupItem(m_hotItem) == S_OK)
+ if (m_hotBar && m_hotItem >= 0 &&
m_hotBar->PopupItem(m_hotItem, TRUE) == S_OK)
return S_FALSE;
if (m_parentBand)
return m_parentBand->_MenuItemHotTrack(VK_RIGHT);
@@ -895,6 +907,8 @@
return S_OK;
return m_subMenuParent->OnSelect(changeType);
}
+
+ return S_OK;
}
HRESULT CMenuBand::_CancelCurrentPopup()
@@ -906,7 +920,7 @@
return hr;
}
-HRESULT CMenuBand::_OnPopupSubMenu(IShellMenu * childShellMenu, POINTL * pAt, RECTL *
pExclude)
+HRESULT CMenuBand::_OnPopupSubMenu(IShellMenu * childShellMenu, POINTL * pAt, RECTL *
pExclude, BOOL keyInitiated)
{
HRESULT hr = 0;
IBandSite* pBandSite;
@@ -942,7 +956,12 @@
else
IUnknown_SetSite(popup, m_site);
- popup->Popup(pAt, pExclude, MPPF_RIGHT);
+ DWORD flags = MPPF_RIGHT;
+
+ if (keyInitiated && m_dwFlags & SMINIT_VERTICAL)
+ flags |= MPPF_INITIALSELECT;
+
+ popup->Popup(pAt, pExclude, flags);
return S_OK;
}
Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuBand.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuBand.h [iso-8859-1] Thu Apr 24
17:42:16 2014
@@ -182,7 +182,7 @@
HRESULT _ChangePopupItem(CMenuToolbarBase * tb, INT id);
HRESULT _MenuItemHotTrack(DWORD changeType);
HRESULT _CancelCurrentPopup();
- HRESULT _OnPopupSubMenu(IShellMenu * childShellMenu, POINTL * pAt, RECTL *
pExclude);
+ HRESULT _OnPopupSubMenu(IShellMenu * childShellMenu, POINTL * pAt, RECTL * pExclude,
BOOL mouseInitiated);
HRESULT _DisableMouseTrack(BOOL bDisable);
HRESULT _SetChildBand(CMenuBand * child);
HRESULT _SetParentBand(CMenuBand * parent);
Modified: branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp [iso-8859-1] Thu Apr 24
17:42:16 2014
@@ -370,6 +370,13 @@
UIActivateIO(TRUE, NULL);
+ if (dwFlags & (MPPF_INITIALSELECT | MPPF_FINALSELECT))
+ {
+ const int CMD_SELECT = 5;
+ int CMD_SELECT_OPTS = dwFlags & MPPF_INITIALSELECT ? 0 : -2;
+ IUnknown_QueryServiceExec(m_Client, SID_SMenuBandChild, &CLSID_MenuBand,
CMD_SELECT, CMD_SELECT_OPTS, NULL, NULL);
+ }
+
return S_OK;
}
Modified: branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1] Thu Apr 24
17:42:16 2014
@@ -558,7 +558,7 @@
return S_FALSE;
// Returns S_FALSE if the current item did not show a submenu
- HRESULT hr = PopupItem(m_hotItem);
+ HRESULT hr = PopupItem(m_hotItem, FALSE);
if (hr != S_FALSE)
return hr;
@@ -613,7 +613,7 @@
if (m_isTrackingPopup && !(m_initFlags & SMINIT_VERTICAL))
{
// If the menubar has an open submenu, switch to the new item's submenu
immediately
- PopupItem(m_hotItem);
+ PopupItem(m_hotItem, FALSE);
}
else if (dwFlags & HICF_MOUSE)
{
@@ -709,7 +709,7 @@
return m_menuBand->_ChangeHotItem(this, btn.idCommand, mouse ? HICF_MOUSE : 0);
}
-HRESULT CMenuToolbarBase::PopupSubMenu(UINT iItem, UINT index, IShellMenu*
childShellMenu)
+HRESULT CMenuToolbarBase::PopupSubMenu(UINT iItem, UINT index, IShellMenu*
childShellMenu, BOOL keyInitiated)
{
// Calculate the submenu position and exclude area
RECT rc = { 0 };
@@ -743,7 +743,7 @@
m_isTrackingPopup = TRUE;
m_menuBand->_ChangePopupItem(this, iItem);
- m_menuBand->_OnPopupSubMenu(childShellMenu, &pt, &rcl);
+ m_menuBand->_OnPopupSubMenu(childShellMenu, &pt, &rcl, keyInitiated);
return S_OK;
}
@@ -816,7 +816,7 @@
INT iItem = (INT)wParam;
- if (PopupItem(iItem) == S_OK)
+ if (PopupItem(iItem, FALSE) == S_OK)
{
TRACE("PopupItem returned S_OK\n");
return S_FALSE;
@@ -1056,7 +1056,7 @@
return m_menuBand->_CancelCurrentPopup();
}
-HRESULT CMenuToolbarBase::PopupItem(INT iItem)
+HRESULT CMenuToolbarBase::PopupItem(INT iItem, BOOL keyInitiated)
{
INT index;
DWORD_PTR dwData;
@@ -1086,7 +1086,7 @@
m_menuBand->_ChangeHotItem(this, iItem, 0);
}
- return InternalPopupItem(iItem, index, dwData);
+ return InternalPopupItem(iItem, index, dwData, keyInitiated);
}
CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand) :
@@ -1209,7 +1209,7 @@
return m_menuBand->_CallCBWithItemId(iItem, SMC_EXEC, 0, 0);
}
-HRESULT CMenuStaticToolbar::InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData)
+HRESULT CMenuStaticToolbar::InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData,
BOOL keyInitiated)
{
SMINFO * nfo = reinterpret_cast<SMINFO*>(dwData);
if (!nfo)
@@ -1226,7 +1226,7 @@
if (FAILED_UNEXPECTEDLY(hr))
return hr;
- return PopupSubMenu(iItem, index, shellMenu);
+ return PopupSubMenu(iItem, index, shellMenu, keyInitiated);
}
}
@@ -1376,7 +1376,7 @@
return m_menuBand->_CallCBWithItemPidl(reinterpret_cast<LPITEMIDLIST>(data),
SMC_SFEXEC, 0, 0);
}
-HRESULT CMenuSFToolbar::InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData)
+HRESULT CMenuSFToolbar::InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL
keyInitiated)
{
HRESULT hr;
UINT uId;
@@ -1410,7 +1410,7 @@
if (FAILED_UNEXPECTEDLY(hr))
return hr;
- return PopupSubMenu(iItem, index, shellMenu);
+ return PopupSubMenu(iItem, index, shellMenu, keyInitiated);
}
HRESULT CMenuSFToolbar::InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData)
Modified: branches/shell-experiments/base/shell/rshell/CMenuToolbars.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuToolbars.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuToolbars.h [iso-8859-1] Thu Apr 24
17:42:16 2014
@@ -71,7 +71,7 @@
HRESULT ChangeHotItem(CMenuToolbarBase * toolbar, INT item, DWORD dwFlags);
HRESULT ChangePopupItem(CMenuToolbarBase * toolbar, INT item);
- HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu);
+ HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu* childShellMenu, BOOL
keyInitiated);
HRESULT PopupSubMenu(UINT itemId, UINT index, HMENU menu);
HRESULT TrackContextMenu(IContextMenu* contextMenu, POINT pt);
@@ -92,7 +92,7 @@
virtual HRESULT FillToolbar(BOOL clearFirst=FALSE) = 0;
HRESULT CancelCurrentPopup();
- HRESULT PopupItem(INT iItem);
+ HRESULT PopupItem(INT iItem, BOOL keyInitiated);
HRESULT GetDataFromId(INT iItem, INT* pIndex, DWORD_PTR* pData);
HRESULT KillPopupTimer();
@@ -102,7 +102,7 @@
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR
pszText, INT cchTextMax) = 0;
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) = 0;
- virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData) = 0;
+ virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL
keyInitiated) = 0;
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) = 0;
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt)
= 0;
@@ -144,7 +144,7 @@
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR
pszText, INT cchTextMax);
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData);
- virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData);
+ virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL
keyInitiated);
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT
pt);
};
@@ -171,7 +171,7 @@
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR
pszText, INT cchTextMax);
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData);
- virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData);
+ virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL
keyInitiated);
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData);
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT
pt);
};