284 |
{ |
{ |
285 |
// Check if this event represents a menu shortcut. |
// Check if this event represents a menu shortcut. |
286 |
|
|
287 |
// MenuShortcuts are activated by Ctrl- KeyEvents. |
// MenuShortcuts are activated by Ctrl- KeyEvents, only on KEY_PRESSED. |
288 |
int modifiers = e.getModifiers (); |
int modifiers = e.getModifiers (); |
289 |
if ((modifiers & KeyEvent.CTRL_MASK) != 0 |
if (e.getID() == KeyEvent.KEY_PRESSED |
290 |
|| (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0) |
&& ((modifiers & KeyEvent.CTRL_MASK) != 0 |
291 |
|
|| (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)) |
292 |
{ |
{ |
293 |
Window focusedWindow = getGlobalFocusedWindow (); |
Window focusedWindow = getGlobalFocusedWindow (); |
294 |
if (focusedWindow instanceof Frame) |
if (focusedWindow instanceof Frame) |
314 |
|
|
315 |
if (shortcut != null) |
if (shortcut != null) |
316 |
{ |
{ |
317 |
// Dispatch a new ActionEvent if this is a |
// Dispatch a new ActionEvent if: |
318 |
// Shift- KeyEvent and the shortcut requires |
// |
319 |
// the Shift modifier, or if the shortcut |
// a) this is a Shift- KeyEvent, and the |
320 |
// doesn't require the Shift modifier. |
// shortcut requires the Shift modifier |
321 |
if ((shortcut.usesShiftModifier () |
// |
322 |
&& ((modifiers & KeyEvent.SHIFT_MASK) != 0 |
// or, b) this is not a Shift- KeyEvent, and the |
323 |
|| (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0) |
// shortcut does not require the Shift |
324 |
|| !shortcut.usesShiftModifier ()) |
// modifier. |
325 |
&& shortcut.getKey () == e.getKeyCode ()) |
if (shortcut.getKey () == e.getKeyCode () |
326 |
|
&& ((shortcut.usesShiftModifier () |
327 |
|
&& ((modifiers & KeyEvent.SHIFT_MASK) != 0 |
328 |
|
|| (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0)) |
329 |
|
|| (! shortcut.usesShiftModifier () |
330 |
|
&& (modifiers & KeyEvent.SHIFT_MASK) == 0 |
331 |
|
&& (modifiers & KeyEvent.SHIFT_DOWN_MASK) == 0))) |
332 |
{ |
{ |
333 |
item.dispatchEvent (new ActionEvent (item, |
item.dispatchEvent (new ActionEvent (item, |
334 |
ActionEvent.ACTION_PERFORMED, |
ActionEvent.ACTION_PERFORMED, |