Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8089373: Translation from character to key code is not sufficient #1126

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -755,7 +755,7 @@ public static int getKeyCodeForChar(char c) {
* The default implementation bridges to the existing getKeyCodeForChar call. Platform
* instances are expected to override this call.
*/
protected boolean _getKeyCanGenerateCharacter(int hardwareCode, int vkCode, char c) {
protected boolean _canKeyGenerateCharacter(int hardwareCode, int vkCode, char c) {
if (vkCode != com.sun.glass.events.KeyEvent.VK_UNDEFINED) {
return getKeyCodeForChar(c) == vkCode;
}
@@ -771,10 +771,10 @@ protected boolean _getKeyCanGenerateCharacter(int hardwareCode, int vkCode, char
* @param hardwareCode the platform-specific key identifier
* @param vkCode the JavaFX key code
* @param c the character
* @return true if the key can generate the character
* @return {@code true} if the key can generate the character
*/
public final boolean getKeyCanGenerateCharacter(int hardwareCode, int vkCode, char c) {
return _getKeyCanGenerateCharacter(hardwareCode, vkCode, c);
public final boolean canKeyGenerateCharacter(int hardwareCode, int vkCode, char c) {
return _canKeyGenerateCharacter(hardwareCode, vkCode, c);
}

protected int _isKeyLocked(int keyCode) {
Original file line number Diff line number Diff line change
@@ -377,13 +377,13 @@ public String getDataDirectory() {

@Override
protected int _getKeyCodeForChar(char c) {
// This platform has migrated to getKeyCanGenerateCharacter
// This platform has migrated to canKeyGenerateCharacter
// so getKeyCodeForChar will no longer be called.
return 0;
throw new UnsupportedOperationException("Windows uses canKeyGenerateCharacter");
}

@Override
protected native boolean _getKeyCanGenerateCharacter(int hardwareCode, int vkCode, char c);
protected native boolean _canKeyGenerateCharacter(int hardwareCode, int vkCode, char c);

@Override
protected native int _isKeyLocked(int keyCode);
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ public void mouseEvent(EventType<MouseEvent> type, double x, double y, double sc
* Pass a key event to the scene to handle
*
* @param keyEvent The key event
* @return true iff the event was consumed
* @return {@code true} if the event was consumed
*/
public boolean keyEvent(KeyEvent keyEvent);

Original file line number Diff line number Diff line change
@@ -706,7 +706,7 @@ protected static final double clampStopOffset(double offset) {
/**
* The default implementation bridges into the existing getKeyCodeForChar call.
*/
public boolean getKeyCanGenerateCharacter(KeyEvent event, String character) {
public boolean canKeyGenerateCharacter(KeyEvent event, String character) {
if (event.getCode() != KeyCode.UNDEFINED) {
return getKeyCodeForChar(character) == event.getCode().getCode();
}
Original file line number Diff line number Diff line change
@@ -165,7 +165,6 @@ public Boolean run() {
PulseLogger.newInput(keyEventType(type).toString());
}
WindowStage stage = scene.getWindowStage();
Boolean consumed = Boolean.FALSE;

try {
boolean shiftDown = (modifiers & KeyEvent.MODIFIER_SHIFT) != 0;
@@ -221,7 +220,7 @@ public Boolean run() {
}
if (scene.sceneListener != null) {
if (scene.sceneListener.keyEvent(keyEvent))
consumed = Boolean.TRUE;
return Boolean.TRUE;
}
break;
default:
@@ -237,7 +236,7 @@ public Boolean run() {
PulseLogger.newInput(null);
}
}
return consumed;
return Boolean.FALSE;
}
}

Original file line number Diff line number Diff line change
@@ -1089,11 +1089,11 @@ public Shape createStrokedShape(Shape shape,

// The Quantum version of this call knows that we may have the hardware key code
// available.
@Override public boolean getKeyCanGenerateCharacter(KeyEvent keyEvent, String character) {
@Override public boolean canKeyGenerateCharacter(KeyEvent keyEvent, String character) {
int hardwareCode = KeyEventHelper.getHardwareCode(keyEvent);
if (keyEvent.getCode() != KeyCode.UNDEFINED || hardwareCode != -1) {
if (character.length() == 1)
return Application.GetApplication().getKeyCanGenerateCharacter(
return Application.GetApplication().canKeyGenerateCharacter(
hardwareCode,
keyEvent.getCode().getCode(),
character.charAt(0));
Original file line number Diff line number Diff line change
@@ -2180,7 +2180,7 @@ private void focusIneligible(Node node) {
}

/**
* @return true iff the event was consumed
* @return {@code true} if the event was consumed
*/
boolean processKeyEvent(KeyEvent e) {
if (dndGesture != null) {
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ public KeyCharacterCombination(final @NamedArg("character") String character,
@Override
public boolean match(final KeyEvent event) {
return (super.match(event) &&
Toolkit.getToolkit().getKeyCanGenerateCharacter(event, getCharacter()));
Toolkit.getToolkit().canKeyGenerateCharacter(event, getCharacter()));
}

/**
Original file line number Diff line number Diff line change
@@ -344,10 +344,10 @@ BOOL IsExtendedKey(UINT vkey) {

/*
* Class: com_sun_glass_ui_win_WinApplication
* Method: _getKeyCanGenerateCharacter
* Method: _canKeyGenerateCharacter
* Signature: (IIC)Z
*/
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_win_WinApplication__1getKeyCanGenerateCharacter
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_win_WinApplication__1canKeyGenerateCharacter
(JNIEnv *env, jobject jApplication, jint hardwareCode, jint vkCode, jchar character)
{
HKL layout = ::GetKeyboardLayout(GlassApplication::GetMainThreadId());