Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Incorrect right alt (AltGr) handling  (Read 2506 times)

0 Members and 1 Guest are viewing this topic.

omeg

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://omeg.pl/
Incorrect right alt (AltGr) handling
« on: August 08, 2011, 09:40:18 pm »
Tested on latest source snapshot, built with VS2010. Window.KeyPressed gets incorrect KeyEventArgs when right alt (AltGr) is pressed. Dump from the debugger (unmodified Window sample):
Code: [Select]
+ e {[KeyEventArgs] Code(LControl) Alt(True) Control(True) Shift(False) System(False)} SFML.Window.KeyEventArgs

You can see that Control flag is set, ant Code is LControl.
Left alt works as expected:
Code: [Select]
+ e {[KeyEventArgs] Code(LAlt) Alt(True) Control(False) Shift(False) System(False)} SFML.Window.KeyEventArgs

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Incorrect right alt (AltGr) handling
« Reply #1 on: August 08, 2011, 10:13:25 pm »
Apparently this is the expected behaviour on Windows. It seems that AltGr is just a shortcut for Ctrl + Alt:
Quote
Note: the AltGr modifier is regarded as identical to Ctrl+Alt by most Windows keyboards.  This is a holdover from the times when many keyboards did not include a right Alt key.  Most keyboards today do include the right Alt key, even many laptop keyboards.


The only workaround that I found, is to turn the left-control event into a right-alt one if the right-alt key is down, but this leads to incorrect results if left-control is pressed while right-alt is down. So I'm still searching for a perfect solution.
Laurent Gomila - SFML developer

omeg

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://omeg.pl/
Incorrect right alt (AltGr) handling
« Reply #2 on: August 08, 2011, 10:22:59 pm »
I see. I've inserted a special check in my code for this case and it's working OK so far. It was messing my keyboard input because some special non-ascii language-specific characters are input by combinations of right alt+letter.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Incorrect right alt (AltGr) handling
« Reply #3 on: August 08, 2011, 10:30:19 pm »
Are you using KeyPressed events for text input?
Laurent Gomila - SFML developer

omeg

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
    • http://omeg.pl/
Incorrect right alt (AltGr) handling
« Reply #4 on: August 08, 2011, 10:36:17 pm »
I was, but I switched to TextEntered. Still, in my KeyPressed handler (used for control characters) I was getting false Ctrl presses from the right alt.