From 06169de6cdf24413efe6be0990297365608606a6 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 5 Jul 2016 13:14:45 +1000 Subject: [PATCH] fix type answer --- aqt/reviewer.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 31a976ead..169bd2884 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -273,7 +273,7 @@ The front of this card is empty. Please run Tools>Empty Cards.""") self.mw.onEditCurrent() elif (key == " " or evt.key() in (Qt.Key_Return, Qt.Key_Enter)): if self.state == "question": - self._showAnswer() + self._getTypedAnswer() elif self.state == "answer": self._answerCard(self._defaultEase()) elif key == "r" or evt.key() == Qt.Key_F5: @@ -299,16 +299,13 @@ The front of this card is empty. Please run Tools>Empty Cards.""") def _linkHandler(self, url): if url == "ans": - self._showAnswer() + self._getTypedAnswer() elif url.startswith("ease"): self._answerCard(int(url[4:])) elif url == "edit": self.mw.onEditCurrent() elif url == "more": self.showContextMenu() - elif url.startswith("typeans:"): - (cmd, arg) = url.split(":", 1) - self.typedAnswer = arg else: openLink(url) @@ -491,6 +488,13 @@ Please run Tools>Empty Cards""") res = "
" + res + "
" return res + def _getTypedAnswer(self): + self.web.evalWithCallback("typeans ? typeans.value : null", self._onTypedAnswer) + + def _onTypedAnswer(self, val): + self.typedAnswer = val + self._showAnswer() + # Bottom bar ##########################################################################