git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of https://github.com/klamonte/jexer
[fanfix.git]
/
src
/
jexer
/
menu
/
TMenu.java
diff --git
a/src/jexer/menu/TMenu.java
b/src/jexer/menu/TMenu.java
index 56cbad5be6661425575ea9039f2392f785b03405..99add703c18fe2d9e59d241bb325b549c16638f1 100644
(file)
--- a/
src/jexer/menu/TMenu.java
+++ b/
src/jexer/menu/TMenu.java
@@
-1,4
+1,4
@@
-/*
*
+/*
* Jexer - Java Text User Interface
*
* License: LGPLv3 or later
* Jexer - Java Text User Interface
*
* License: LGPLv3 or later
@@
-128,7
+128,7
@@
public final class TMenu extends TWindow {
public void draw() {
CellAttributes background = getTheme().getColor("tmenu");
public void draw() {
CellAttributes background = getTheme().getColor("tmenu");
- assert (
get
AbsoluteActive());
+ assert (
is
AbsoluteActive());
// Fill in the interior background
for (int i = 0; i < getHeight(); i++) {
// Fill in the interior background
for (int i = 0; i < getHeight(); i++) {
@@
-221,7
+221,7
@@
public final class TMenu extends TWindow {
// See if we should activate a different menu item
for (TWidget widget: getChildren()) {
// See if we should activate a different menu item
for (TWidget widget: getChildren()) {
- if ((mouse.
get
Mouse1())
+ if ((mouse.
is
Mouse1())
&& (widget.mouseWouldHit(mouse))
) {
// Activate this menu item
&& (widget.mouseWouldHit(mouse))
) {
// Activate this menu item
@@
-241,8
+241,16
@@
public final class TMenu extends TWindow {
*/
@Override
public void onKeypress(final TKeypressEvent keypress) {
*/
@Override
public void onKeypress(final TKeypressEvent keypress) {
- if (getActiveChild() != null) {
- if (getActiveChild() instanceof TSubMenu) {
+
+ /*
+ System.err.printf("keypress: %s active child: %s\n", keypress,
+ getActiveChild());
+ */
+
+ if (getActiveChild() != this) {
+ if ((getActiveChild() instanceof TSubMenu)
+ || (getActiveChild() instanceof TMenu)
+ ) {
getActiveChild().onKeypress(keypress);
return;
}
getActiveChild().onKeypress(keypress);
return;
}
@@
-261,9
+269,7
@@
public final class TMenu extends TWindow {
return;
}
if (keypress.equals(kbRight)) {
return;
}
if (keypress.equals(kbRight)) {
- if (!isSubMenu) {
- getApplication().switchMenu(true);
- }
+ getApplication().switchMenu(true);
return;
}
if (keypress.equals(kbLeft)) {
return;
}
if (keypress.equals(kbLeft)) {
@@
-276,14
+282,14
@@
public final class TMenu extends TWindow {
}
// Switch to a menuItem if it has an mnemonic
}
// Switch to a menuItem if it has an mnemonic
- if (!keypress.getKey().
getIs
Key()
- && !keypress.getKey().
get
Alt()
- && !keypress.getKey().
get
Ctrl()) {
+ if (!keypress.getKey().
isFn
Key()
+ && !keypress.getKey().
is
Alt()
+ && !keypress.getKey().
is
Ctrl()) {
for (TWidget widget: getChildren()) {
TMenuItem item = (TMenuItem) widget;
if ((item.getMnemonic() != null)
&& (Character.toLowerCase(item.getMnemonic().getShortcut())
for (TWidget widget: getChildren()) {
TMenuItem item = (TMenuItem) widget;
if ((item.getMnemonic() != null)
&& (Character.toLowerCase(item.getMnemonic().getShortcut())
- == Character.toLowerCase(keypress.getKey().getCh()))
+ == Character.toLowerCase(keypress.getKey().getCh
ar
()))
) {
// Send an enter keystroke to it
activate(item);
) {
// Send an enter keystroke to it
activate(item);
@@
-295,7
+301,7
@@
public final class TMenu extends TWindow {
// Dispatch the keypress to an active widget
for (TWidget widget: getChildren()) {
// Dispatch the keypress to an active widget
for (TWidget widget: getChildren()) {
- if (widget.
get
Active()) {
+ if (widget.
is
Active()) {
widget.handleEvent(keypress);
return;
}
widget.handleEvent(keypress);
return;
}