Can i remap a button on the keyboard? (trying to support copy/paste on mac)

my app runs cross-platform, and on the mac os x, copy/pasting is accomplished via ctrl+c/v, when the native os wants to use cmd-c/v. (ie in order to copy from a browser and paste into my java app, the user would have to press cmd-c to copy from the mac environment and then ctrl-v to paste into the java environment.)
i'd like to have copy/paste behave the way mac users are expecting (pressing cmd vice ctrl). at the moment, my app supports OS functions like cmd-w (close window), cmd-q (quit), and cmd-h (hide) via a few import classes from apple. they neglect to provide the same support for copy/pasting.
so. how can i init my java environment so that if a user presses the cmd key, java behaves as if they are pressing the ctrl key?
thanks!

ok, tested it. seems that under metal and the L&F i'm using (which is based on metal as far as i know), pasting is accomplished via ctrl-v.
if i set the L&F to the system L&F while running in a mac os, pasting is accomplished via cmd-c (meta-c?).
so that's that.
i asked google for help with the shortcutKeyMask, and this turned up on an apple site:
Accelerators (Keyboard Shortcuts)
Do not set menu item accelerators with an explicit javax.swing.KeyStroke specification. Modifier keys vary from platform to platform. Instead, use java.awt.Tookit.getMenuShortcutKeyMask to ask the system for the appropriate key rather than defining it yourself.
When calling this method, the current platform�s Toolkit implementation returns the proper mask for you. This single call checks for the current platform and then guesses which key is correct. In the case of adding a Copy item to a menu, using getMenuShortcutKeyMask means that you can replace the complexity of �The Contents of an Application Bundle� with the simplicity of Listing 2.
Listing 1  Explicitly setting accelerators based on the host platform
JMenuItem jmi = new JMenuItem("Copy");
    String vers = System.getProperty("os.name").toLowerCase();
    if (s.indexOf("windows") != -1) {
       jmi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    } else if (s.indexOf("mac") != -1) {
       jmi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.META_MASK));
Listing 2  Using getMenuShortcutKeyMask to set modifier keys
JMenuItem jmi = new JMenuItem("Copy");
jmi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
    Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
The default modifier key in Mac OS X is the Command key. There may be additional modifier keys like Shift, Option, or Control, but the Command key is the primary key that alerts an application that a command, not regular input follows. Note that not all platforms provide this consistency in user interface behavior. When assigning keyboard shortcuts to items for menu items, make sure that you are not overriding any of the keyboard commands Macintosh users are accustomed to. See Apple Human Interface Guidelines for the definitive list of the most common and reserved keyboard shortcuts (keyboard equivalents).
okay... but uh... i don't quite get it. seems that this Listing 2 solution might work, but a) this is for a menu and b) i'd like this to be a global setting if at all possible. my concern is when i use something like this:
JOptionPane.showInputDialog(jframe,
                                          "please enter some text",
                                          "input dialog",
                                          JOptionPane.OK_OPTION);i want this to be paste-able too!
thanks!

Similar Messages

  • I can't change the brightness on my macbook pro. i tried the buttons on the keyboard, went to settings and tried to do it from there, didn't work. i have restarted my computer as well and that didn't make a difference. please help

    i can't change the brightness on my macbook pro. i tried the buttons on the keyboard, went to settings and tried to do it from there, didn't work. i have restarted my computer as well and that didn't make a difference. please help.

    Reset the PRAM and SMC.
    Barry

  • Hi Guys! I have an Imac with Mac OS X version 10.5.8 and bought a wireless keyboard. Unfortunately I can´t use the volume buttons on the keyboard. I have checked almost everything, does anyone have any good idea?

    Hi Guys! I have an Imac with Mac OS X version 10.5.8 and bought a wireless keyboard. Unfortunately I can´t use the volume buttons on the keyboard. I have checked almost everything, does anyone have any good idea?

    Hello, try kguy's solution here...
    https://discussions.apple.com/thread/2332457?start=0&tstart=0
    First, Go to System Preferences, keyboard, and click on the Keyboard tab
    Make sure that the checkbox by "Use all F1, F2, etc, keys as standard function keys" is NOT checked.
    Next, click on the Show All button, and select Bluetooth. You should see your Apple Wireless Keyboard listed on the left side of the screen.
    Click once to select it, and then click the gear icon at the bottom of the box, and choose Disconnect.
    Power off the keyboard by holding down the power button on the keyboard for a few seconds until it show "keyboard Off on your imac screen, then turn it back on again.
    The device should appear once again in your bluetooth list.
    Try out the volume control buttons now, and see if that cleared things up

  • How can I prevent Aperture from playing slideshow when hitting the play button on the keyboard?

    I am getting a bit frustrated by the fact that the play button on the keyboard, which I use all the time for controlling audio playback in iTunes and now Spotify, is assigned to starting the slideshow in Aperture. Playing a slideshow is something I never use, and is something that causes the beachball of death to appear every time. It does not make sense to me that the slideshow overrules the audio playback in iTunes. Help is much appreciated...

    In Aperture the keyboard shortcuts are defined in the Command Editor.
    To open the Command Editor,  go to the Aperture menu -> Commands -> Customize
    and in the search field enter "slideshow". Remove or replace the key binding you find there, if it is the one you want to use in iTunes.

  • My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?

    My iMac 24 can no longer be paired with the keyboard; it doesn't recognise any keyboard at boot up, even the one it is paired with. Can anyone help, please?
    Thank. Simon

    Brian - The batteries are fine and there has only every been one keyboard paired with it. We have tried my MacPro keyboard as well, and it will not even recognise that there is a discoverable keyboard nearby.
    Thanks, Simon

  • One button of the keyboard doesn't work correctly

    Hi there,
    I have a problem with my keyboard:
    One button of the keyboard doesn??t work correctly: I want to write down a vowel with an accent (like in French and Spanish?), but if I press the button ´ and then the vowel, TWO dashes (´´) and the vowel appear: ´´i. Normally, there would automatically be an accent on top of the i.
    I have already tried a different keyboard, but it??s the same problem when I connect it to my notebook. I have also tried to choose a different language like French and Spanish, where they have those accents, but it still doesn??t work.
    It would be great if somebody could help me.
    Thanks a lot,
    Hanna

    Hi Hannah,
    You do not say which options you have changed to try using a different language, but there are several options which do slightly different things.
    If you go into Control Panel and select "Regional and Language Options", a new window opens with 3 tabs across the top. Choose "Languages" (the middle one), then press the "Details" button. This opens another window which allows you to view and change settings including the current input language and keyboard settings.
    Changing some of these settings will not make any difference until you reboot your machine.
    I hope this helps, let us know how you get on!
    Weezle

  • HT3131 I would like to darken my Mac Air screen, so I can use may external display and the keyboard on the notebook--it is possible on a PC-does it work on a Mac?

    I would like to darken my Mac Air screen, so I can use may external display and the keyboard on the notebook--it is possible on a PC-does it work on a Mac?

    Sure it's possible.
    Go to System Preferences (under the Apple logo on the top left of the menu).
    Choose "Display".  There's a slider bar for the screen brightness.  Adjust it and you're all set.

  • Hi do someone now how to fix this "when i press Tab button on the keyboard the cursor don't move to the next string control"

    When i press Tab button on the keyboard the cursor don't move to the next password control. i have simple login dialog in web ui builder.
    When i run the vix i need to press two times Tab to move from username string control to the next password "password control" my Tab index for the username
    control is "1" and for the password is "2' and i try to use all of the 3 options for TabNavigation Local, Cycle and Once and noone work.
    Thanks

    I attached one simple example of the issue.
    Thanks for the Reply.
    Attachments:
    Login Dialog.zip ‏2 KB

  • How do I reinstall the edit button on my Firefox 4 toolbar; cut, copy, paste, and print?

    I recently have been having problems with my Firefox 4 tool bars. Right now, the Edit icons are no longer on the tool bar, specifically Cut, Copy, Paste, and Print. If there were other Edit icons, they too are gone. All the other icons have remained.
    I would appreciate it if you could advise me how to reinstall those specific icons.
    Also recently, ALL my tool bars, and task and status bar disappeared. This was only in Firefox 4.0; IE 8 was not affected. Clicking F11 did not work. I could not function without them. Then, a short time later, they "automatically" reappeared. I have not idea of why the disappeared or reappeared.
    Thank you for any help you can provide.
    Sanford A. Berman

    You can find the Copy, Paste, and Cut buttons next to Firefox > Edit (and in its sub menu) and in the regular Edit menu on the menu bar (press F10 if the menu bar is hidden).
    The buttons next to Firefox > Edit are enabled if there is something to do with them, just like with the toolbar buttons.
    You can find the Copy, Paste, and Cut toolbar buttons in the toolbar palette in the Customize window and drag them on a toolbar.
    Open the Customize window via "View > Toolbars > Customize" or via "Firefox > Options > Toolbar Layout"
    *http://kb.mozillazine.org/Toolbar_customization
    *https://support.mozilla.com/kb/Back+and+forward+or+other+toolbar+items+are+missing

  • I have a mac osx version 10.6.8 no windows and i am trying to install a program but keep getting can not run in dos mode  ( the disk says on back works on intel mac with parallels or vm fusion) is this program not compatible with my mac?

    i have a mac osx version 10.6.8 no windows installed and i am trying to install a program but keep getting can not run in dos mode  ( the disk says on back works on intel mac with parallels or vm fusion) is this program not compatible with my mac?

    You run Windows in Parallels or Fusion. Then in Windows you install the program.

  • How can I delete songs stored in the Cloud but without deleting them from my mac?

    How can I delete songs stored in the Cloud but without deleting them from my mac?

    You can do it, but you need another library signed in to iTunes match. That second library shouldn't have any local files stored.
    Delete the entry from that second library and it will ask you to confirm that you want to remove the file from the cloud. Confirm that you do.
    Now, as long as you don't delete the file from your main library it will have an iCloud status of "removed" and won't be in the cloud or try add it again.
    However, if you sign out of match on that computer and then sign in again it will then re-add it to the cloud, so this isn't a method to use if you tend to turn match on and off much.
    I have had the Beatles Mono albums in my main library, but not in the cloud, for a while now without any problems.

  • I have just bought a 2011 iMac (2.5 ghz, 4gb) and logic express 9, and when i installed logic and tried to run it i had a message saying 'you can't use this version of the application logic express with this version of Mac OS X. How do i sort this out!?

    I have just bought a 2011 iMac (2.5 ghz, 4gb) and logic express 9, and when i installed logic and tried to run it i had a message saying 'you can't use this version of the application logic express with this version of Mac OS X. How do i sort this out!? It is very frustrating as the main reason i have bought  a mac is to use logic! Any help would be great as i am a complete novice when it comes to Macs!

    You're probably on OS X Lion?
    I had the same problem as you. I used Software Update to update Logic Express to the latest version, and then it ran without any problems.

  • Just got my Mac air and i would like to make a file to store some web addresses for my new business with rodan and fields and I can't do it. Made the file but i cant copy and paste the web addresses in the file to save them. Please help and thank you.

    Just got my Mac air and i would like to make a file to store some web addresses for my new business with rodan and fields and I can't do it. Made the file but i cant copy and paste the web addresses in the file to save them. Please help and thank you.

    Yes - well you have to make the file in a word processing Application.
    You could use TextEdit (it's free) Pages (words only), or Numbers (data base) (they are part of iWorks - and may or may not be free (included) on your machine.  You could use MS Office (it is not free) You could use any Open source word processor that plays well with Office (NeoOffice, StarOffice) they are free.
    That's how you create content and copy/paste URLS. Then you save the file to the desktop. If you are going to make more than one file... you make a folder on the desktop and save, or drag the file(s) into it.
    You attach it to your e-mail client which will compress it and e-mail it. An excellent reference is to use Help, from the menu bar, also from inside any application. From your library or book store the OS X for Dummies has a lot of useful information (you don't read it cover to cover but look up chapters about what you'd like to do)
    You can also make appointments at your local Apple store for individualized help (if a store is nearby)

  • Unable to open mail, address book etc due to this message:  You can't use this version of the application Address Book with this version of Mac OS X. HELP!

    I am transferring my mother's address book and mail etc to my computer from an external hard drive enclosure and am not able to open it due to this message:  You can't use this version of the application Address Book with this version of Mac OS X. HELP!  Is there a way to open her older applications and get the info out?

    her email is in user>Library>Mail folder. Hopefully you've created another user on your Mac for your mother so she would have her own user Library.

  • You can't use this version of the application Logic Pro with this version of Mac OS X.

    You can't use this version of the application Logic Pro with this version of Mac OS X. why am i getting this message after upgrading to lion

    <Bump>
    See this thread.
    https://discussions.apple.com/message/15700842#15700842
    and this one.
    https://discussions.apple.com/message/15700505#15700505
    pancenter-

Maybe you are looking for

  • Addnode.bat has no effect

    Hello I try to add a new node with the addnode.bat file but it ditn't work. The File calls the setup.exe but it shows no window and there is no task in the taskmanager. The OS is Windows Server 2008R2. 4GB RAM. I try it with Oracle 11.2

  • Loader persistence.xml

    How does the JVM loader META-INF/persistence.xml? any help greatly appreciated!

  • Comms6 IM java.lang.NoClassDefFoundError: org/apache/log4j/Layout

    Hi, After install (and configure) Comms6 Instant Messaging Server I cannot turn on IM services: bash-3.00# svcadm enable sunim bash-3.00# svcs -xv svc:/application/sunim:default (Sun Instant Messaging Server) State: offline since Thu Sep 18 18:57:15

  • Oracle 9i and XP

    quick question here...trying to install 9i on my laptop running XP service pack 2. is this possible? when i click the setup file it starts to work (about .25s worth of hourglass spin) and then stops. i was reading on the site that this combination is

  • HP4635 Changed wireless router can't set up new one

    How do I change keyboard from alpha to numeric so that I can enter my new password in the wireless setup wizard?