Home » Developing U++ » Mac OS » [BUG] keyboard shortcuts problem on an AZERTY keyboard
[BUG] keyboard shortcuts problem on an AZERTY keyboard [message #52350] |
Fri, 13 September 2019 12:43  |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi,
- when i press '⌘ + W', theide detect '⌘ + Z'
- when i press '⌘ + Z', theide detect '⌘ + W'
- when i press '⌘ + A', theide detect '⌘ + Q'
and so.
but normal text work well : - when i press 'W', theide detect 'W'
System :
MacOS Mojave
10.14.6
regards
omari.
|
|
|
Re: [BUG] keyboard shortcuts problem on an AZERTY keyboard [message #52405 is a reply to message #52350] |
Fri, 20 September 2019 19:19   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi,
after investigation, i found that :
- we use NSEvent.keyCode as source of keyevent
- NSEvent.keyCode is layout independent.
for example, the key that labeled 'Q' in a QWERTY keyboard send alwayse the keyCode '0x0C' , even in an AZERTY keyboard when this key is labeled 'A'. - keyevent management is in the file CocoProc.mm, function
static bool KeyEvent(Upp::Ctrl *ctrl, NSEvent *e, int up) ;
it seam that the solution is to use NSEvent.charactersIgnoringModifiers instead of NSEvent.keyCode.
regards
omari.
[Updated on: Fri, 20 September 2019 19:20] Report message to a moderator
|
|
|
Re: [BUG] keyboard shortcuts problem on an AZERTY keyboard [message #52406 is a reply to message #52405] |
Fri, 20 September 2019 19:42   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
this modified function handle A,Q, Z and W correctly.
static bool KeyEvent(Upp::Ctrl *ctrl, NSEvent *e, int up) {
Flags(e);
if(!ctrl->IsEnabled())
return false;
Upp::dword k = e.keyCode;
WString x = ToWString((CFStringRef)(e.charactersIgnoringModifiers));
if(x.GetCount() == 1)
{
int c = ToUpper(x[0]);
switch(c)
{
case 'A' : k = kVK_ANSI_A; break;
case 'Q' : k = kVK_ANSI_Q; break;
case 'Z' : k = kVK_ANSI_Z; break;
case 'W' : k = kVK_ANSI_W; break;
// ... need to map all characters
}
}
k = (k == kVK_ANSI_KeypadEnter ? K_ENTER : k)|K_DELTA|up;
if(GetCtrl())
k |= K_CTRL;
if(GetShift())
k |= K_SHIFT;
if(GetAlt())
k |= K_ALT;
if(GetOption())
k |= K_OPTION;
if(e.keyCode == kVK_Help) // TODO: This is Insert key, but all this is dubious
ctrl->DispatchKey(k & ~K_KEYUP, 1);
LogNSEv(e);
ctrl->DispatchKey(k, 1);
if(!up && !(k & (K_CTRL|K_ALT))) {
WString x = ToWString((CFStringRef)(e.characters));
for(wchar c : x) {
if(c < 0xF700 &&
(c > 32 && c != 127 || c == 9 && !GetOption() || c == 32 && !GetShift()))
ctrl->DispatchKey(c, 1);
}
if(e.keyCode == kVK_ANSI_KeypadEnter && *x != 13)
ctrl->DispatchKey(13, 1);
}
return true;
}
i will try to find the map for all keycodes later.
regards
omari.
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 17:47:16 CEST 2025
Total time taken to generate the page: 0.00717 seconds
|