Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

capturing the copy command



Apologies for asking what is probably an oft-repeated question, but I can't get anything useful out of that horrid archives interface.

Anyway, I'm trying to capture the command-C command in a custom JTable component. I've already a custom subclass of AbstractAction and configured with the following line:

putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

Then, I use this action to create a JMenu item by adding it to my edit menu. Pretty standard stuff.

The problem is that when I hit "command-C" on my keyboard, my custom Action is not invoked. I can invoke the Action by clicking on the menu with the mouse, but invoking it with the configured KeyStroke accelerator doesn't work. If I change the accelerator char to something like 'L', then I can press "command-L" on my keyboard, and my Action will execute. Other, similarly-configured actions behave as expected - e.g. "command-N" executes a custom action to open a new window, "command-O" opens my custom file chooser dialog, etc. All of this is true of the Paste command as well, which I will also need to customize.

So clearly, "command-C" (and "command-V") is already mapped to some component whose keymap is ahead of my component's keymap in whatever search order swing is using to find actions to perform (if I understand the mechanism correctly). So what do I need to do to hijack this behaviour?

Any help is much appreciated,
Cheers,
Erskine
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.