mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-03-02 23:13:40 +01:00
Allow pressing the down arrow key to show the completion popup
Also have the enter key close the completion popup, applying any selected completion first.
This commit is contained in:
parent
55ca95bb34
commit
028241eb0e
2 changed files with 12 additions and 1 deletions
|
|
@ -37,6 +37,11 @@ def onkeydown(self, event):
|
|||
event.preventDefault(), event.stopPropagation()
|
||||
return
|
||||
if event.key is 'Enter':
|
||||
if self.completion_popup.is_visible:
|
||||
if self.apply_completion(self.completion_popup.current_text):
|
||||
self.completion_popup.hide()
|
||||
event.preventDefault(), event.stopPropagation()
|
||||
return
|
||||
if self.onenterkey:
|
||||
event.preventDefault(), event.stopPropagation()
|
||||
self.onenterkey()
|
||||
|
|
@ -47,6 +52,12 @@ def onkeydown(self, event):
|
|||
else:
|
||||
self.completion_popup.move_highlight()
|
||||
event.preventDefault(), event.stopPropagation()
|
||||
elif event.key is 'ArrowDown':
|
||||
ti = self.text_input
|
||||
if not ti.value:
|
||||
self.completion_popup.set_query('')
|
||||
self.completion_popup.popup(ti)
|
||||
event.preventDefault(), event.stopPropagation()
|
||||
|
||||
def oninput(self, event):
|
||||
ti = self.text_input
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def is_visible(self):
|
|||
def set_all_items(self, items):
|
||||
self.items = list(items)
|
||||
self.matches = []
|
||||
self.applied_query = ''
|
||||
self.applied_query = None
|
||||
|
||||
def add_associated_widget(self, widget_or_id):
|
||||
if jstype(widget_or_id) is not 'string':
|
||||
|
|
|
|||
Loading…
Reference in a new issue