Exemplo n.º 1
0
	def _get_keyboardShortcut(self):
		bindings=self.jabContext.getAccessibleKeyBindings()
		if not bindings or bindings.keyBindingsCount<1: 
			return None
		shortcutsList=[]
		for index in range(bindings.keyBindingsCount):
			binding=bindings.keyBindingInfo[index]
			# We don't support these modifiers
			if binding.modifiers & (
				JABHandler.AccessibleKeystroke.META
				| JABHandler.AccessibleKeystroke.ALT_GRAPH
				| JABHandler.AccessibleKeystroke.BUTTON1
				| JABHandler.AccessibleKeystroke.BUTTON2
				| JABHandler.AccessibleKeystroke.BUTTON3
			):
				continue
			modifiers = binding.modifiers
			# We assume alt  if there are no modifiers at all and its not a menu item as this is clearly a nmonic
			if not modifiers and self.role != controlTypes.Role.MENUITEM:
				modifiers |= JABHandler.AccessibleKeystroke.ALT
			keyList = [
				keyLabels.localizedKeyLabels.get(l, l)
				for l in JABHandler._getKeyLabels(modifiers, binding.character)
			]
			shortcutsList.append("+".join(keyList))
		return ", ".join(shortcutsList)
Exemplo n.º 2
0
	def testFKeyShortcut(self):
		for c in FKEY_SHORTCUTS:
			for modifierCombination in MODIFIER_COMBINATIONS:
				modifiers = AccessibleKeystroke.FKEY
				modLabels = []
				for m, l in modifierCombination.items():
					modifiers |= m
					modLabels.append(l)
				with self.subTest(fkey=ord(c), modifiers=modifiers, modLabels=modLabels):
					expected = modLabels + ["F{}".format(ord(c))]
					self.assertListEqual(expected, JABHandler._getKeyLabels(modifiers, c))
Exemplo n.º 3
0
	def testControlCodeShortcut(self):
		for c, v in JABHandler.JABKeyControlCodesToLabels.items():
			for modifierCombination in MODIFIER_COMBINATIONS:
				modifiers = AccessibleKeystroke.CONTROLCODE
				modLabels = []
				for m, l in modifierCombination.items():
					modifiers |= m
					modLabels.append(l)
				with self.subTest(controlCode=c, label=v, modifiers=modifiers, modLabels=modLabels):
					expected = modLabels + [v]
					self.assertListEqual(expected, JABHandler._getKeyLabels(modifiers, chr(c)))
Exemplo n.º 4
0
	def testBasicShortcut(self):
		for c in BASIC_SHORTCUT_KEYS:
			for modifierCombination in MODIFIER_COMBINATIONS:
				modifiers = 0
				modLabels = []
				for m, l in modifierCombination.items():
					modifiers |= m
					modLabels.append(l)
				with self.subTest(character=c, modifiers=modifiers, modLabels=modLabels):
					expected = modLabels + [c]
					self.assertListEqual(expected, JABHandler._getKeyLabels(modifiers, c))