Skip to content

Commit

Permalink
fixes bug where copy/paste were blocked when keyhandler was active
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremymarch committed May 31, 2022
1 parent 21bfd63 commit 64e25b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/HKToolbar.xcu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<node oor:name="AddonUI">
<node oor:name="OfficeToolBar">
<node oor:name="com.philolog.hoplitekb.toolbar" oor:op="replace">
<node oor:name="button1" oor:op="replace">
<node oor:name="com.philolog.hoplitekb.button1" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>com.philolog.hoplitekb:open</value>
</prop>
Expand Down
Binary file modified src/images/hop24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/hop48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions src/py/hoplitekb.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ def __init__(self, parent):
def dispatch(self, url, args):
self.state = not self.state
ev = self.create_simple_event(url, self.state)
self.listener.statusChanged(ev)

self.listener.statusChanged(ev) #this shades the button to indicate toggled state
self.toggle_action()

def addStatusListener(self, listener, url):
Expand All @@ -167,7 +166,7 @@ def removeStatusListener(self, listener, url): pass
def controlEvent(self, ev): pass

def create_simple_event(self, url, state, enabled=True):
return FeatureStateEvent(self, url, "", enabled, False, state) #this shades the button to indicate toggled state
return FeatureStateEvent(self, url, "", enabled, False, state)

def toggle_action(self):
if self.state == False:
Expand All @@ -182,6 +181,13 @@ def __init__(self, parent, ctx):
self.ctx = ctx

def keyPressed(self, oEvent):
#do not interfere with modified keys except shift
#1 shift SHIFT
#2 control/command MOD1
#4 alt MOD2
#8 control on macOS MOD3
if oEvent.Modifiers != 0 and oEvent.Modifiers != 1:
return False
letter = oEvent.KeyChar.value
if letter.isnumeric():
self.parent.toggleDiacritic(letter)
Expand Down Expand Up @@ -292,6 +298,7 @@ def queryDispatch(self, url, name, flag):
dispatch = Dispatcher(self)
except Exception as e:
print(e)
#insertString(self.ctx, str(e))
return dispatch

def queryDispatches(self, requests):
Expand Down

0 comments on commit 64e25b1

Please sign in to comment.