using left to close submenu and right to open it
This commit is contained in:
parent
b4aba1ff12
commit
8890bfe946
1 changed files with 31 additions and 63 deletions
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// $Id: Menu.cc,v 1.26 2003/07/03 12:23:28 fluxgen Exp $
|
// $Id: Menu.cc,v 1.27 2003/07/03 12:47:22 fluxgen Exp $
|
||||||
|
|
||||||
//use GNU extensions
|
//use GNU extensions
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
|
@ -320,11 +320,6 @@ void Menu::nextItem() {
|
||||||
else
|
else
|
||||||
drawItem(which_press, true, true, true);
|
drawItem(which_press, true, true, true);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
cerr<<__FILE__<<"("<<__FUNCTION__<<")"<<endl;
|
|
||||||
cerr<<"which_press = "<<which_press<<endl;
|
|
||||||
#endif // DEBUG
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::prevItem() {
|
void Menu::prevItem() {
|
||||||
|
@ -354,11 +349,33 @@ void Menu::prevItem() {
|
||||||
drawItem(which_press, true, true, true);
|
drawItem(which_press, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
}
|
||||||
cerr<<__FILE__<<"("<<__FUNCTION__<<")"<<endl;
|
|
||||||
cerr<<"which_press = "<<which_press<<endl;
|
|
||||||
#endif // DEBUG
|
|
||||||
|
|
||||||
|
void Menu::enterSubmenu() {
|
||||||
|
if (which_press < 0 || which_press >= menuitems.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Menu *submenu = menuitems[which_press]->submenu();
|
||||||
|
if (submenu == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
submenu->grabInputFocus();
|
||||||
|
submenu->which_press = -1; // so we land on 0 after nextItem()
|
||||||
|
submenu->nextItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Menu::enterParent() {
|
||||||
|
if (which_press < 0 || which_press >= menuitems.size() || parent() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Menu *submenu = menuitems[which_press]->submenu();
|
||||||
|
if (submenu)
|
||||||
|
submenu->menu.window.hide();
|
||||||
|
|
||||||
|
drawItem(which_press, false, true, true);
|
||||||
|
which_press = -1; // dont select any in this
|
||||||
|
// return focus to parent but keep this window open
|
||||||
|
parent()->grabInputFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::disableTitle() {
|
void Menu::disableTitle() {
|
||||||
|
@ -1259,33 +1276,6 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::enterSubmenu() {
|
|
||||||
if (which_press < 0 || which_press >= menuitems.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Menu *submenu = menuitems[which_press]->submenu();
|
|
||||||
if (submenu == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
submenu->grabInputFocus();
|
|
||||||
submenu->which_press = -1; // so we land on 0 after nextItem()
|
|
||||||
submenu->nextItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::enterParent() {
|
|
||||||
if (which_press < 0 || which_press >= menuitems.size() || parent() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Menu *submenu = menuitems[which_press]->submenu();
|
|
||||||
if (submenu)
|
|
||||||
submenu->menu.window.hide();
|
|
||||||
|
|
||||||
drawItem(which_press, false, true, true);
|
|
||||||
which_press = -1; // dont select any in this
|
|
||||||
// return focus to parent but keep this window open
|
|
||||||
parent()->grabInputFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::keyPressEvent(XKeyEvent &event) {
|
void Menu::keyPressEvent(XKeyEvent &event) {
|
||||||
KeySym ks;
|
KeySym ks;
|
||||||
char keychar[1];
|
char keychar[1];
|
||||||
|
@ -1303,33 +1293,11 @@ void Menu::keyPressEvent(XKeyEvent &event) {
|
||||||
case XK_Down:
|
case XK_Down:
|
||||||
nextItem();
|
nextItem();
|
||||||
break;
|
break;
|
||||||
case XK_Left: // enter submenu or leave this menu and enter parent
|
case XK_Left: // enter parent if we have one
|
||||||
// if we have a submenu we should determine if
|
|
||||||
// we should open it or close this and enter parent depending on which
|
|
||||||
// side the parent is.
|
|
||||||
// if parent on the left -> enter parent
|
|
||||||
// if parent on the right -> enter submenu of this item
|
|
||||||
if (which_press >= 0 && which_press < menuitems.size()) {
|
|
||||||
Menu *submenu = menuitems[which_press]->submenu();
|
|
||||||
if (parent() && parent()->x() < x()) // parent on the left
|
|
||||||
enterParent();
|
enterParent();
|
||||||
else if (submenu) // else parent on the right and submenu on the left
|
|
||||||
enterSubmenu();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case XK_Right: // enter submenu or leave this menu and enter parent
|
case XK_Right: // enter submenu if we have one
|
||||||
// if we have a submenu we should determine if
|
|
||||||
// we should open it or close this and enter parent depending on which
|
|
||||||
// side the parent is.
|
|
||||||
// if parent on the left -> enter submenu of this item
|
|
||||||
// parent on the right -> leave this menu and enter parent
|
|
||||||
if (which_press >= 0 && which_press < menuitems.size()) {
|
|
||||||
Menu *submenu = menuitems[which_press]->submenu();
|
|
||||||
if (parent() && parent()->x() > x()) // parent on the right
|
|
||||||
enterParent();
|
|
||||||
else if (submenu) // else parent on the left and submenu on the right
|
|
||||||
enterSubmenu();
|
enterSubmenu();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case XK_Escape: // close menu
|
case XK_Escape: // close menu
|
||||||
hide();
|
hide();
|
||||||
|
|
Loading…
Reference in a new issue