From 45b5b8e0df8f5851c31127e839f936032bbf73db Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Wed, 23 Nov 2011 16:43:21 +0100 Subject: [PATCH] settings: ensure the textinput is not focused when dismiss the popup. closes #314 --- kivy/uix/settings.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kivy/uix/settings.py b/kivy/uix/settings.py index 27a5e076a..edfbb1c68 100644 --- a/kivy/uix/settings.py +++ b/kivy/uix/settings.py @@ -317,9 +317,15 @@ class SettingString(SettingItem): return self.bind(on_release=self._create_popup) - def _validate(self, instance): - self.popup.dismiss() + def _dismiss(self, *largs): + if self.textinput: + self.textinput.focus = False + if self.popup: + self.popup.dismiss() self.popup = None + + def _validate(self, instance): + self._dismiss() value = self.textinput.text.strip() if value == '': return @@ -349,7 +355,7 @@ class SettingString(SettingItem): btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') - btn.bind(on_release=popup.dismiss) + btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) @@ -365,13 +371,11 @@ class SettingNumeric(SettingString): ''' def _validate(self, instance): - self.popup.dismiss() - self.popup = None + self._dismiss() try: - value = int(self.textinput.text) + self.value = int(self.textinput.text) except ValueError: return - self.value = value class SettingOptions(SettingItem):