Only show lists when the entry has focus

This commit is contained in:
CMDR-Kiel42 2020-07-18 23:56:17 +02:00
parent 7e119f6c90
commit 40f8cbcf30
2 changed files with 8 additions and 8 deletions

View File

@ -50,11 +50,11 @@ class AutoCompleter(PlaceHolder):
self.foc_in()
w = e.widget
self.menu.entryconfigure("Cut",
command=lambda: w.event_generate("<<Cut>>"))
command=lambda: w.event_generate("<<Cut>>"))
self.menu.entryconfigure("Copy",
command=lambda: w.event_generate("<<Copy>>"))
command=lambda: w.event_generate("<<Copy>>"))
self.menu.entryconfigure("Paste",
command=lambda: w.event_generate("<<Paste>>"))
command=lambda: w.event_generate("<<Paste>>"))
self.menu.tk.call("tk_popup", self.menu, e.x_root, e.y_root)
def keypressed(self, event):
@ -133,7 +133,7 @@ class AutoCompleter(PlaceHolder):
def show_list(self, height):
self.lb["height"] = height
if not self.lb_up:
if not self.lb_up and self.parent.focus_get() is self:
info = self.grid_info()
if info:
self.lb.grid(row=int(info["row"])+1, columnspan=2)

View File

@ -135,9 +135,9 @@ class SpanshRouter():
self.source_ac.put_placeholder()
if len(self.dest_ac.var.get()) == 0:
self.dest_ac.put_placeholder()
self.source_ac.ac_foc_out()
self.source_ac.hide_list()
self.source_ac.grid_remove()
self.dest_ac.ac_foc_out()
self.dest_ac.hide_list()
self.dest_ac.grid_remove()
self.range_entry.grid_remove()
self.efficiency_slider.grid_remove()
@ -366,8 +366,8 @@ class SpanshRouter():
efficiency = self.efficiency_slider.get()
# Hide autocomplete lists in case they're still shown
self.source_ac.ac_foc_out()
self.dest_ac.ac_foc_out()
self.source_ac.hide_list()
self.dest_ac.hide_list()
if ( source and source != self.source_ac.placeholder and
dest and dest != self.dest_ac.placeholder ):