Skip to content

Commit

Permalink
When a Modifier key release matches a hotkey command, return False no…
Browse files Browse the repository at this point in the history
…t True.

Resolves: #269
  • Loading branch information
mike-fabian committed Jan 28, 2022
1 parent 3b70a6f commit b01e055
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions engine/hunspell_table.py
Expand Up @@ -5258,7 +5258,7 @@ def _command_remove_candidate_9(self) -> bool:
def _handle_hotkeys(
self,
key: itb_util.KeyEvent,
commands: Iterable[str] = ()) -> bool:
commands: Iterable[str] = ()) -> Tuple[bool, bool]:
'''Handle hotkey commands
:return: True if the key was completely handled, False if not.
Expand Down Expand Up @@ -5298,7 +5298,7 @@ def _handle_hotkeys(
# part of a valid compose sequence. That has
# priority so it cannot be used as a hotkey in
# that case
return False
return (False, False)
self._typed_compose_sequence.pop()
self._update_transliterated_strings()
self._update_preedit()
Expand All @@ -5311,12 +5311,19 @@ def _handle_hotkeys(
command_function_name)
if hotkey_removed_from_compose_sequence:
self._typed_compose_sequence.append(key.val)
return False
return (False, False)
if command_function():
return True
if key.name in ('Shift_L', 'Shift_R',
'Control_L', 'Control_R',
'Alt_L', 'Alt_R',
'Meta_L', 'Meta_R',
'Super_L', 'Super_R',
'ISO_Level3_Shift'):
return (True, False)
return (True, True)
if hotkey_removed_from_compose_sequence:
self._typed_compose_sequence.append(key.val)
return False
return (False, False)

def _return_false(self, keyval: int, keycode: int, state: int) -> bool:
'''A replacement for “return False” in do_process_key_event()
Expand Down Expand Up @@ -5460,7 +5467,7 @@ def _handle_compose(self, key: itb_util.KeyEvent) -> bool:
[IBus.keyval_name(val)
for val in self._typed_compose_sequence],
repr(compose_result))
if self._handle_hotkeys(
(match, return_value) = self._handle_hotkeys(
key, commands=['cancel',
'toggle_input_mode_on_off',
'enable_lookup',
Expand All @@ -5485,8 +5492,9 @@ def _handle_compose(self, key: itb_util.KeyEvent) -> bool:
'commit_candidate_8',
'commit_candidate_8_plus_space',
'commit_candidate_9',
'commit_candidate_9_plus_space']):
return True
'commit_candidate_9_plus_space'])
if match:
return return_value
if (self._lookup_table_shows_compose_completions
and self.get_lookup_table().cursor_visible):
# something is manually selected in the compose lookup table
Expand Down Expand Up @@ -5584,17 +5592,20 @@ def do_process_key_event(
if self._handle_compose(key):
return True

if self._handle_hotkeys(key, commands=['toggle_input_mode_on_off']):
return True
(match, return_value) = self._handle_hotkeys(
key, commands=['toggle_input_mode_on_off'])
if match:
return return_value

if (not self._input_mode
or (self._input_purpose
in [itb_util.InputPurpose.PASSWORD,
itb_util.InputPurpose.PIN])):
return self._return_false(keyval, keycode, state)

if self._handle_hotkeys(key):
return True
(match, return_value) = self._handle_hotkeys(key)
if match:
return return_value

result = self._process_key_event(key)
self._prev_key = key
Expand Down

0 comments on commit b01e055

Please sign in to comment.