settings: ensure the textinput is not focused when dismiss the popup. closes #314

This commit is contained in:
Mathieu Virbel 2011-11-23 16:43:21 +01:00
parent 1d6a0389a7
commit 45b5b8e0df
1 changed files with 11 additions and 7 deletions

View File

@ -317,9 +317,15 @@ class SettingString(SettingItem):
return
self.bind(on_release=self._create_popup)
def _validate(self, instance):
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):