Merge pull request #778 from hgiesel/refocus

Always focus main web instead of bottom web in reviewer
This commit is contained in:
Damien Elmes 2020-10-07 16:22:49 +10:00 committed by GitHub
commit 301c9587d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 11 deletions

View file

@ -201,8 +201,6 @@ class Reviewer:
self._drawFlag()
self._drawMark()
self._showAnswerButton()
# if we have a type answer field, focus main web
if self.typeCorrect:
self.mw.web.setFocus()
# user hook
gui_hooks.reviewer_did_show_question(c)
@ -242,6 +240,7 @@ class Reviewer:
# render and update bottom
self.web.eval("_showAnswer(%s);" % json.dumps(a))
self._showEaseButtons()
self.mw.web.setFocus()
# user hook
gui_hooks.reviewer_did_show_answer(c)
@ -574,11 +573,9 @@ time = %(time)d;
)
def _showAnswerButton(self) -> None:
if not self.typeCorrect:
self.bottom.web.setFocus()
middle = """
<span class=stattxt>%s</span><br>
<button title="%s" id=ansbut onclick='pycmd("ans");'>%s</button>""" % (
<button title="%s" id="ansbut" class="focus" onclick='pycmd("ans");'>%s</button>""" % (
self._remaining(),
_("Shortcut key: %s") % _("Space"),
_("Show Answer"),
@ -596,7 +593,6 @@ time = %(time)d;
self.bottom.web.adjustHeightToFit()
def _showEaseButtons(self) -> None:
self.bottom.web.setFocus()
middle = self._answerButtons()
self.bottom.web.eval("showAnswer(%s);" % json.dumps(middle))
@ -648,7 +644,7 @@ time = %(time)d;
def but(i, label):
if i == default:
extra = "id=defease"
extra = """id="defease" class="focus" """
else:
extra = ""
due = self._buttonTime(i)

View file

@ -33,7 +33,21 @@ button {
white-space: nowrap;
}
#ansbut { margin-bottom: 1em; }
#ansbut {
margin-bottom: 1em;
}
.focus {
outline: 5px auto rgba(0, 103, 244, 0.247);
#innertable:focus-within & {
outline: unset;
&:focus {
outline: 5px auto rgba(0, 103, 244, 0.247);
}
}
}
.nobold {
font-weight: normal;

View file

@ -36,14 +36,12 @@ let updateTime = function () {
function showQuestion(txt, maxTime_) {
// much faster than jquery's .html()
$("#middle")[0].innerHTML = txt;
$("#ansbut").focus();
time = 0;
maxTime = maxTime_;
}
function showAnswer(txt) {
$("#middle")[0].innerHTML = txt;
$("#defease").focus();
}
function selectedAnswerButton() {