Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
omari is currently offline  omari
Messages: 193
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 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 193
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 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 193
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.
Re: [BUG] keyboard shortcuts problem on an AZERTY keyboard [message #52411 is a reply to message #52406] Sat, 21 September 2019 20:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12118
Registered: November 2005
Ultimate Member
Technically speking, those codes do not need to be kVK_ANSI_*... They can be whatever is defined in CocoKeys.h.
Re: [BUG] keyboard shortcuts problem on an AZERTY keyboard [message #52433 is a reply to message #52411] Fri, 27 September 2019 14:23 Go to previous message
mirek is currently offline  mirek
Messages: 12118
Registered: November 2005
Ultimate Member
I have expanded your fix to all keys (in rather primitive way) and commited to trunk. Thanks.

Mirek
Previous Topic: [BUG] Context Menu does not work properly
Goto Forum:
  


Current Time: Sun Dec 08 07:11:46 CET 2019

Total time taken to generate the page: 0.00873 seconds