Lines 47-58
Link Here
|
47 |
keyboardFocusManager.addKeyEventPostProcessor(this); |
47 |
keyboardFocusManager.addKeyEventPostProcessor(this); |
48 |
} |
48 |
} |
49 |
|
49 |
|
|
|
50 |
|
51 |
private KeyEvent lastKeyPressed; // which posted a popup from main menu |
52 |
|
50 |
public boolean postProcessKeyEvent(KeyEvent ev) { |
53 |
public boolean postProcessKeyEvent(KeyEvent ev) { |
51 |
if (ev.isConsumed()) |
54 |
if (ev.isConsumed()) |
52 |
return false; |
55 |
return false; |
53 |
|
|
|
54 |
// force run of any pending activation requests |
55 |
DefaultContainerImpl.runPendingNodeActivator(); |
56 |
|
56 |
|
57 |
KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev); |
57 |
KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev); |
58 |
Window w = SwingUtilities.windowForComponent(ev.getComponent()); |
58 |
Window w = SwingUtilities.windowForComponent(ev.getComponent()); |
Lines 75-91
Link Here
|
75 |
ev.consume(); |
75 |
ev.consume(); |
76 |
return true; |
76 |
return true; |
77 |
} |
77 |
} |
78 |
|
|
|
79 |
JFrame mw = WindowManagerImpl.mainWindow(); |
80 |
if (mw == w) |
81 |
return false; |
82 |
|
83 |
JMenuBar mb = mw.getJMenuBar(); |
84 |
if (mb == null) |
85 |
return false; |
86 |
boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED); |
87 |
|
88 |
invokeProcessKeyBindingsForAllComponents(ev, mw, pressed); |
89 |
return false; |
78 |
return false; |
90 |
} |
79 |
} |
91 |
|
80 |
|
Lines 100-110
Link Here
|
100 |
ev.setModifiers(mods); |
89 |
ev.setModifiers(mods); |
101 |
} |
90 |
} |
102 |
} |
91 |
} |
|
|
92 |
|
93 |
// force run of any pending activation requests |
94 |
DefaultContainerImpl.runPendingNodeActivator(); |
103 |
|
95 |
|
|
|
96 |
JFrame mw = WindowManagerImpl.mainWindow(); |
97 |
Window w = SwingUtilities.windowForComponent(ev.getComponent()); |
98 |
|
104 |
MenuElement[] arr = MenuSelectionManager.defaultManager().getSelectedPath(); |
99 |
MenuElement[] arr = MenuSelectionManager.defaultManager().getSelectedPath(); |
105 |
if (arr == null || arr.length == 0) |
100 |
if (arr == null || arr.length == 0) { |
106 |
return false; |
101 |
if (w instanceof Dialog) { |
|
|
102 |
return false; |
103 |
} |
104 |
|
105 |
JMenuBar mb = mw.getJMenuBar(); |
106 |
if (mb == null) |
107 |
return false; |
108 |
boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED); |
109 |
|
110 |
boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed); |
111 |
if (res) { |
112 |
ev.consume(); |
113 |
lastKeyPressed = ev; |
114 |
} |
115 |
else { |
116 |
lastKeyPressed = null; |
117 |
} |
118 |
return res; |
119 |
} |
107 |
|
120 |
|
|
|
121 |
if (lastKeyPressed != null |
122 |
&& ev.getID() == KeyEvent.KEY_TYPED |
123 |
&& lastKeyPressed.getModifiers() == InputEvent.ALT_MASK |
124 |
&& ev.getModifiers() == InputEvent.ALT_MASK |
125 |
&& lastKeyPressed.getKeyChar() == ev.getKeyChar() |
126 |
) { |
127 |
ev.consume(); |
128 |
return true; |
129 |
} |
130 |
|
108 |
MenuSelectionManager.defaultManager().processKeyEvent(ev); |
131 |
MenuSelectionManager.defaultManager().processKeyEvent(ev); |
109 |
|
132 |
|
110 |
if (!ev.isConsumed() && arr[0] instanceof JMenuBar) { |
133 |
if (!ev.isConsumed() && arr[0] instanceof JMenuBar) { |
Lines 132-138
Link Here
|
132 |
|
155 |
|
133 |
return false; |
156 |
return false; |
134 |
} |
157 |
} |
135 |
|
158 |
|
136 |
/** |
159 |
/** |
137 |
* Checks to see if a given keystroke is bound to an action which should |
160 |
* Checks to see if a given keystroke is bound to an action which should |
138 |
* function on all focused components. This includes the Main Window, |
161 |
* function on all focused components. This includes the Main Window, |