mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 19:26:32 +00:00
keyboard navigation in start menu using first character of display names
svn path=/branches/lean-explorer/; revision=8343
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 7.6 KiB |
@@ -541,6 +541,10 @@ void StartMenu::ProcessKey(int vk)
|
||||
case VK_ESCAPE:
|
||||
CloseStartMenu();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (vk>='0' && vk<='Z')
|
||||
JumpToNextShortcut(vk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,6 +571,56 @@ bool StartMenu::Navigate(int step)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StartMenu::JumpToNextShortcut(char c)
|
||||
{
|
||||
int cur_idx = GetSelectionIndex();
|
||||
|
||||
if (cur_idx == -1)
|
||||
cur_idx = 0;
|
||||
|
||||
int first_found = 0;
|
||||
int found_more = 0;
|
||||
|
||||
SMBtnVector::const_iterator cur_it = _buttons.begin();
|
||||
cur_it += cur_idx + 1;
|
||||
|
||||
// first search down from current item...
|
||||
SMBtnVector::const_iterator it = cur_it;
|
||||
for(; it!=_buttons.end(); ++it) {
|
||||
const SMBtnInfo& btn = *it;
|
||||
|
||||
if (!btn._title.empty() && toupper((TBYTE)btn._title.at(0)) == c) {
|
||||
if (!first_found)
|
||||
first_found = btn._id;
|
||||
else
|
||||
++found_more;
|
||||
}
|
||||
}
|
||||
|
||||
// ...now search from top to the current item
|
||||
it = _buttons.begin();
|
||||
for(; it!=_buttons.end() && it!=cur_it; ++it) {
|
||||
const SMBtnInfo& btn = *it;
|
||||
|
||||
if (!btn._title.empty() && toupper((TBYTE)btn._title.at(0)) == c) {
|
||||
if (!first_found)
|
||||
first_found = btn._id;
|
||||
else
|
||||
++found_more;
|
||||
}
|
||||
}
|
||||
|
||||
if (first_found) {
|
||||
SelectButton(first_found);
|
||||
|
||||
if (!found_more)
|
||||
Command(first_found, BN_CLICKED);
|
||||
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // _LIGHT_STARTMENU
|
||||
|
||||
|
||||
|
||||
@@ -258,6 +258,7 @@ protected:
|
||||
virtual void ProcessKey(int vk);
|
||||
bool Navigate(int step);
|
||||
bool OpenSubmenu(bool select_first=false);
|
||||
bool JumpToNextShortcut(char c);
|
||||
#endif
|
||||
|
||||
// member functions
|
||||
|
||||
Reference in New Issue
Block a user