[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Mac OSX and German Keyboard Layout (Y/Z)
From:       Tom Schindl <tom.schindl () bestsolution ! at>
Date:       2016-01-22 12:30:01
Message-ID: 56A220C9.8030104 () bestsolution ! at
[Download RAW message or body]

Hi,

I just discovered that the KeyCode reported by JavaFX on OS-X with a
german keyboard layout (where eg z and y are interchanged) is wrong.

If you press a Z you get as the KeyCode.Y and for Y you get KeyCode.Z -
this Y/Z problem. I don't think that I as a java-dev need to deal with
that and if you look at other toolkits (swing, swt) they handle this
transparently for me!

I've attached you a javafx and swing application and you'll notice that
swing reports always the correct keycode (no matter if my keyboard
layout is english or german) and javafx is wrong on german keyboards.


FX:
> package application;
> 
> import javafx.application.Application;
> import javafx.scene.Scene;
> import javafx.scene.control.TextField;
> import javafx.scene.layout.BorderPane;
> import javafx.stage.Stage;
> 
> 
> public class Main extends Application {
> 	@Override
> 	public void start(Stage primaryStage) {
> 		try {
> 			BorderPane root = new BorderPane();
> 
> 			TextField f = new TextField();
> 			f.setOnKeyPressed( e -> {
> 				System.err.println("KeyCode: " + e.getCode());
> 			});
> 
> 			root.setCenter(f);
> 
> 			Scene scene = new Scene(root,400,400);
> 			primaryStage.setScene(scene);
> 			primaryStage.show();
> 		} catch(Exception e) {
> 			e.printStackTrace();
> 		}
> 	}
> 
> 	public static void main(String[] args) {
> 		launch(args);
> 	}
> }

Swing:
> package application;
> 
> import java.awt.event.KeyEvent;
> import java.awt.event.KeyListener;
> 
> import javax.swing.JFrame;
> import javax.swing.JTextField;
> 
> public class SampleSwing extends JFrame {
> 	public SampleSwing() {
> 		JTextField textField = new JTextField();
> 		textField.addKeyListener(new KeyListener() {
> 
> 			@Override
> 			public void keyTyped(KeyEvent e) {
> 				// TODO Auto-generated method stub
> 
> 			}
> 
> 			@Override
> 			public void keyReleased(KeyEvent e) {
> 				// TODO Auto-generated method stub
> 
> 			}
> 
> 			@Override
> 			public void keyPressed(KeyEvent e) {
> 				System.err.println((char)e.getKeyCode());
> 			}
> 		});
> 		getContentPane().add(textField);
> 	}
> 
> 	public static void main(String[] args) {
> 		new SampleSwing().setVisible(true);
> 
> 	}
> }



Tom

-- 
Thomas Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7, A-6020 Innsbruck
http://www.bestsolution.at/
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic