mirror of https://github.com/kivy/kivy.git
settings: ensure the textinput is not focused when dismiss the popup. closes #314
This commit is contained in:
parent
1d6a0389a7
commit
45b5b8e0df
|
@ -317,9 +317,15 @@ class SettingString(SettingItem):
|
||||||
return
|
return
|
||||||
self.bind(on_release=self._create_popup)
|
self.bind(on_release=self._create_popup)
|
||||||
|
|
||||||
def _validate(self, instance):
|
def _dismiss(self, *largs):
|
||||||
self.popup.dismiss()
|
if self.textinput:
|
||||||
|
self.textinput.focus = False
|
||||||
|
if self.popup:
|
||||||
|
self.popup.dismiss()
|
||||||
self.popup = None
|
self.popup = None
|
||||||
|
|
||||||
|
def _validate(self, instance):
|
||||||
|
self._dismiss()
|
||||||
value = self.textinput.text.strip()
|
value = self.textinput.text.strip()
|
||||||
if value == '':
|
if value == '':
|
||||||
return
|
return
|
||||||
|
@ -349,7 +355,7 @@ class SettingString(SettingItem):
|
||||||
btn.bind(on_release=self._validate)
|
btn.bind(on_release=self._validate)
|
||||||
btnlayout.add_widget(btn)
|
btnlayout.add_widget(btn)
|
||||||
btn = Button(text='Cancel')
|
btn = Button(text='Cancel')
|
||||||
btn.bind(on_release=popup.dismiss)
|
btn.bind(on_release=self._dismiss)
|
||||||
btnlayout.add_widget(btn)
|
btnlayout.add_widget(btn)
|
||||||
content.add_widget(btnlayout)
|
content.add_widget(btnlayout)
|
||||||
|
|
||||||
|
@ -365,13 +371,11 @@ class SettingNumeric(SettingString):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def _validate(self, instance):
|
def _validate(self, instance):
|
||||||
self.popup.dismiss()
|
self._dismiss()
|
||||||
self.popup = None
|
|
||||||
try:
|
try:
|
||||||
value = int(self.textinput.text)
|
self.value = int(self.textinput.text)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return
|
return
|
||||||
self.value = value
|
|
||||||
|
|
||||||
|
|
||||||
class SettingOptions(SettingItem):
|
class SettingOptions(SettingItem):
|
||||||
|
|
Loading…
Reference in New Issue