mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
enter/space should use selected answer button
https://anki.tenderapp.com/discussions/ankidesktop/29882-selecting-a-button-and-enter-or-space-always-chooses-good
This commit is contained in:
parent
8ef88cd15d
commit
49096da7f8
2 changed files with 17 additions and 2 deletions
|
@ -273,6 +273,13 @@ The front of this card is empty. Please run Tools>Empty Cards.""")
|
||||||
if self.state == "question":
|
if self.state == "question":
|
||||||
self._getTypedAnswer()
|
self._getTypedAnswer()
|
||||||
elif self.state == "answer":
|
elif self.state == "answer":
|
||||||
|
self.bottom.web.evalWithCallback("selectedAnswerButton()", self._onAnswerButton)
|
||||||
|
|
||||||
|
def _onAnswerButton(self, val):
|
||||||
|
# button selected?
|
||||||
|
if val in "1234":
|
||||||
|
self._answerCard(int(val))
|
||||||
|
else:
|
||||||
self._answerCard(self._defaultEase())
|
self._answerCard(self._defaultEase())
|
||||||
|
|
||||||
def _linkHandler(self, url):
|
def _linkHandler(self, url):
|
||||||
|
@ -542,8 +549,8 @@ time = %(time)d;
|
||||||
extra = ""
|
extra = ""
|
||||||
due = self._buttonTime(i)
|
due = self._buttonTime(i)
|
||||||
return '''
|
return '''
|
||||||
<td align=center>%s<button %s title="%s" onclick='pycmd("ease%d");'>\
|
<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, label)
|
%s</button></td>''' % (due, extra, _("Shortcut key: %s") % i, i, i, label)
|
||||||
buf = "<center><table cellpading=0 cellspacing=0><tr>"
|
buf = "<center><table cellpading=0 cellspacing=0><tr>"
|
||||||
for ease, label in self._answerButtonList():
|
for ease, label in self._answerButtonList():
|
||||||
buf += but(ease, label)
|
buf += but(ease, label)
|
||||||
|
|
|
@ -41,3 +41,11 @@ function showAnswer(txt) {
|
||||||
$("#middle")[0].innerHTML = txt;
|
$("#middle")[0].innerHTML = txt;
|
||||||
$("#defease").focus();
|
$("#defease").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectedAnswerButton() {
|
||||||
|
var node = document.activeElement;
|
||||||
|
if (!node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return node.dataset.ease;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue