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

The Strength+ and Strength- hotkeys for weights do not work #798

Open
misaki-eymard opened this issue Jun 12, 2024 · 3 comments
Open

The Strength+ and Strength- hotkeys for weights do not work #798

misaki-eymard opened this issue Jun 12, 2024 · 3 comments
Assignees
Labels

Comments

@misaki-eymard
Copy link

Description:
The following hotkeys for changing the Strength for Add or Remove Weight mode does not seem to be working:

  • Weights - Strength+: opt + '''
  • Weights - Strength-: opt + ';'

Expected behavior:
When you are selecting Add or Remove in the weight view, you can change the Strength using the corresponding hotkey.

Steps to reproduce:

  1. Open Spine 4.2.29 and create new project.
  2. Open the Weight view and set the mode to Add or Remove.
  3. Press the Strength+ or Strength- hotkey.

The version of Spine in which this issue was found:
Spine 4.2.29

@NathanSweet
Copy link
Member

I find it works on Windows. Maybe this is a macOS bug.

@misaki-eymard
Copy link
Author

Sorry, my test was not sufficient. I confirmed that it works if you change the default key to another key, although I tried it on Mac PC. Changing the following key settings made it work:
Weights - Strength+: N
Weights - Strength-: O

Also, I found that even with the default key settings, holding down ctrl works. There should be no reason why "opt + key" combinations should not work, since hotkeys for opening views, such as opt + A to open the Animation view, work. So in any case, I think there may be some issues specific to Mac PCs.

@davidetan
Copy link
Collaborator

davidetan commented Jun 19, 2024

The problem is related to the fact that when you press opt on Mac, then you get another character:

  • opt + ' produce the char æ (keycode is 75 that is the same of ')
  • opt + ; produce the char (keycode is 74 that is the same of ;)

Also:

  • opt + A produce the char å (keycode is 29 that is the same of a)

However during hotkeys initialization there is an important difference. In Hotkeys#load the hotkeys are initialized like this:

  • opt + ': { keycode: 0, keyName: ', character: ' }
  • opt + ;: { keycode: 0, keyName: ;, character: ; }
  • opt + A: { keycode: 29, keyName: A, character: A }

Keycode is 0 for the first two cases because the code doesn't enter this if (repeat is true):

if (!repeat || keyName.length() != 1) {
	try {
		keycode = (Integer)Input.Keys.class.getField(keyName).get(null);
	} catch (Throwable ex) {
		errors.add($("Invalid key name: ") + originalKeyName);
	}
}

and in any case it seems there is no mapping available in Input.Keys for the two keys above.

Consequently, when Hotkeys.fire(char character) is triggered typing opt + ', we receive æ as character and the line:

Array<Hotkey> charHotkeys = characterToHotkeys.get(character);

won't find the keyword corresponding to opt + '.
This is confirmed by the fact that if I change the hotkey to opt + æ, they hotkeys is triggered.

The reason why typing opt + A works even though it sends the character å, is because there is also the Hotkeys.fire(int keycode).
Pressing opt + A will send the keycode 29 that is registered in the hotkeys.
The line:

Array<Hotkey> keycodeHotkeys = keycodeToHotkeys.get(keycode);

is able to find the corresponding keycode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants