Skip to content

Commit

Permalink
Show correct shortcut keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashlynn Anderson committed Oct 29, 2020
1 parent ec2404b commit dfd3548
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,33 @@

## CHANGE ANSWER BUTTONS TO PASS/FAIL ##

# Hardcoding the shortcut keys is a lazy solution,
# but one I'm reasonably okay with
def pfAnswerButtonList(self):
l = ((1, _("Fail")),)
l = ((1, _("Fail"), _("Shortcut key: 1")),)
cnt = self.mw.col.sched.answerButtons(self.card)
if cnt == 2 or cnt == 3:
return l + ((2, _("Pass")),)
return l + ((2, _("Pass"), _("Shortcut keys: 2, 3, 4")),)
else:
return l + ((3, _("Pass")),)
return l + ((3, _("Pass"), _("Shortcut keys: 2, 3, 4")),)

# For some reason it's necessary to copy over this function instead of
# just wrapping _answerButtonList, I couldn't say why.
def pfAnswerButtons(self, _old):
default = self._defaultEase()
def but(i, label):
def but(i, label, shortcutDialog):
cnt = self.mw.col.sched.answerButtons(self.card)
if i == default:
extra = "id=defease"
else:
extra = ""
due = self._buttonTime(i)
return '''
<td align=center>%s<button %s title="%s" data-ease="%s" onclick='pycmd("ease%d");'>\
%s</button></td>''' % (due, extra, _("Shortcut key: %s") % i, i, i, label)
%s</button></td>''' % (due, extra, shortcutDialog, i, i, label)
buf = "<center><table cellpading=0 cellspacing=0><tr>"
for ease, label in pfAnswerButtonList(self):
buf += but(ease, label)
for ease, label, shortcutDialog in pfAnswerButtonList(self):
buf += but(ease, label, shortcutDialog)
buf += "</tr></table>"
script = """
<script>$(function () { $("#defease").focus(); });</script>"""
Expand Down

0 comments on commit dfd3548

Please sign in to comment.