mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04: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
@ -37,6 +37,11 @@ class EditWithComplete:
|
||||
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 @@ class EditWithComplete:
|
||||
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 @@ class CompletionPopup:
|
||||
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…
x
Reference in New Issue
Block a user