keyboard navigation in start menu using first character of display names

svn path=/trunk/; revision=8344
This commit is contained in:
Martin Fuchs 2004-02-23 22:17:01 +00:00
parent 47d8d8ba89
commit 60f5689a70
3 changed files with 56 additions and 1 deletions

View file

@ -3,7 +3,7 @@
<tr>
<td><address style="align: right;"><small>
ROS Explorer Source Code Documentation
<br>generated on 22.02.2004 by <a href="http://www.doxygen.org/index.html">
<br>generated on 23.02.2004 by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0>
</small></address>
</td>

View file

@ -542,6 +542,10 @@ void StartMenu::ProcessKey(int vk)
case VK_ESCAPE:
CloseStartMenu();
break;
default:
if (vk>='0' && vk<='Z')
JumpToNextShortcut(vk);
}
}
@ -568,6 +572,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

View file

@ -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