Skip to content

Commit

Permalink
Update kvui.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvris committed Feb 3, 2025
1 parent 671e24e commit 00cda6c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kvui.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,14 @@ def on_items(self, instance, value: list) -> None:

class AutocompleteHintInput(MDTextField):
min_chars = NumericProperty(3)
attach_to: bool = False

def __init__(self, **kwargs):
super().__init__(**kwargs)

self.dropdown = MarkupDropdown(caller=self, position="bottom", border_margin=dp(24), width=dp(400))
self.dropdown = MarkupDropdown(caller=self, position="bottom", border_margin=dp(24), width=self.width)
self.dropdown.bind(on_select=lambda instance, x: setattr(self, 'text', x))
self.bind(on_text_validate=self.on_message)
self.bind(width=lambda instance, x: setattr(self.dropdown, "width", x))

def on_message(self, instance):
MDApp.get_running_app().commandprocessor("!hint "+instance.text)
Expand Down Expand Up @@ -497,12 +497,10 @@ def on_press(text):
"on_release": lambda: on_press(text),
"markup": True
})
if not self.attach_to:
if not self.dropdown.parent:
self.dropdown.open()
self.attach_to = True
else:
self.dropdown.dismiss()
self.attach_to = False


status_icons = {
Expand Down

0 comments on commit 00cda6c

Please sign in to comment.