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
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 previous message
omari is currently offline  omari
Messages: 265
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.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [Fixed] Context Menu does not work properly
Next Topic: Cannot compile MYSQL project
Goto Forum:
  


Current Time: Sun May 05 07:49:59 CEST 2024

Total time taken to generate the page: 0.02703 seconds