Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Adding OS X support  (Read 1509 times)
0 Members and 1 Guest are viewing this topic.
Offline Death33284

Junior Devvie





« Posted 2006-08-08 04:12:57 »

How can I check if the command/apple key is down on macs? I use right click in my game, but I would also like for mac users to be able to command + click. Now, I see isShiftDown, isControlDown, and isAltDown, but no isCommandDown or someting of that sort. I'm guessing you have to use the getModifiers command, but I cannot really test this as I have no immediate access to a computer running OS X.
Offline CommanderKeith
« Reply #1 - Posted 2006-08-08 04:50:54 »

I think there's a method called KeyEvent.isMetaDown() or there is a KeyEvent.VK_META.  I don't have a Mac so don't know for sure but I think that does the trick. 

I'd actually like to know how the 'windows' key can be detected, if anyone knows?

Offline Kova

Senior Devvie





« Reply #2 - Posted 2006-08-08 10:47:58 »

there was some topic not so long ago about that... you need to include 3rd party libs for command or windows button to work since they are platform specific. There is a link to that libs... find topic.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pepijnve

Junior Devvie




Java games rock!


« Reply #3 - Posted 2006-08-09 15:03:30 »

Right click is performed by holding down control, not command. Also, I was under the impression that the control click was interpreted as a right cick automagically. I'll test it this evening and let you know.
Offline pepijnve

Junior Devvie




Java games rock!


« Reply #4 - Posted 2006-08-09 16:06:57 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
JPanel panel = new JPanel();
panel.addMouseListener(new MouseInputAdapter() {
  public void mouseClicked(MouseEvent mouseEvent) {
    System.out.println("Test.mouseClicked");
    if (SwingUtilities.isLeftMouseButton(mouseEvent)) {
      System.out.println("Left click");
    }
    if (SwingUtilities.isMiddleMouseButton(mouseEvent)) {
      System.out.println("Middle click");
    }
    if (SwingUtilities.isRightMouseButton(mouseEvent)) {
      System.out.println("Right click");
    }

    System.out.println("button = " + mouseEvent.getButton());
    System.out.println("popupTrigger = " + mouseEvent.isPopupTrigger());
    System.out.println("modifiers = " + mouseEvent.getModifiers());
    System.out.println("modifiersEx = " + mouseEvent.getModifiersEx());
    System.out.println("altDown = " + mouseEvent.isAltDown());
    System.out.println("altGraphDown = " + mouseEvent.isAltGraphDown());
    System.out.println("controlDown = " + mouseEvent.isControlDown());
    System.out.println("metaDown = " + mouseEvent.isMetaDown());
    System.out.println("shiftDown = " + mouseEvent.isShiftDown());
  }
});

Using this bit of code I get the following results on my powerbook:
Control + click:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
Test.mouseClicked
Left click
button = 1
popupTrigger = false
modifiers = 18
modifiersEx = 128
altDown = false
altGraphDown = false
controlDown = true
metaDown = false
shiftDown = false

Command + click:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
Test.mouseClicked
Left click
Right click
button = 1
popupTrigger = false
modifiers = 20
modifiersEx = 256
altDown = false
altGraphDown = false
controlDown = false
metaDown = true
shiftDown = false

So no magic conversion from control click to right click. SwingUtilities does interpret meta (command) click as a right mouse button though. This is strange since the rest of the OS interprets control click as a right click.
Offline Death33284

Junior Devvie





« Reply #5 - Posted 2006-08-10 19:32:06 »

Yeah, sorta odd

I had no clue the "apple" key was also refered to as "meta"

I did get it working with command + click in my checkers game, check it out in the games showcase if you want
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #6 - Posted 2006-08-10 22:00:21 »

I had no clue the "apple" key was also refered to as "meta"

That's 'cause it isn't Smiley.  The META key in the JRE is mapped to different keys on different platforms.  I'm not sure, but I wouldn't be surprized if it maps to the "windows" key that some PC keyboards have.  On a Mac the "Apple" key is called the "Command" key.  The "alt" key on a Mac is shown on the keyboard with the word "option" and "alt" in little tiny letters to the side.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (37 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!