From 89eef411c4323240780541b72cd8db4453d20157 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 24 Oct 2019 14:15:57 +0530 Subject: [PATCH] Make custom font size panel more keyboard friendly --- src/pyj/read_book/prefs/font_size.pyj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/prefs/font_size.pyj b/src/pyj/read_book/prefs/font_size.pyj index bf3a0b5891..7ad7c24c7e 100644 --- a/src/pyj/read_book/prefs/font_size.pyj +++ b/src/pyj/read_book/prefs/font_size.pyj @@ -48,6 +48,7 @@ def show_custom_size(ev): for child in c.childNodes: child.style.display = 'none' c.lastChild.style.display = 'block' + c.lastChild.querySelector('input').focus() def create_font_size_panel(container, close): container.appendChild(E.div(id=CONTAINER, @@ -70,7 +71,14 @@ def create_font_size_panel(container, close): )) container.appendChild(E.div(style='display:none', - E.div(E.label(_('Font size (pixels):'), '\xa0', E.input(type='number', min=8, max=60, step=1, value=str(sd.get('base_font_size'))))), + E.div(E.label(_('Font size (pixels):'), '\xa0', E.input( + type='number', min=8, max=60, step=1, + value=sd.get('base_font_size') + '', + onkeydown=def(evt): + if evt.key is 'Enter': + evt.preventDefault() + set_custom_size(), close() + ))), E.div(style='text-align:right; margin-top:1ex; display:flex; justify-content: flex-end', create_button(_('OK'), 'check', def(): set_custom_size(), close();), E.span('\xa0'), create_button(_('Cancel'), action=close)