mirror of https://github.com/kivy/kivy.git
Merge pull request #613 from esbullington/spinner_mod
Modified spinner to close on (re-)click
This commit is contained in:
commit
355f49c30e
|
@ -139,6 +139,14 @@ class DropDown(ScrollView):
|
|||
default to True.
|
||||
'''
|
||||
|
||||
is_open = BooleanProperty(False)
|
||||
'''By default, the dropdown is not open. Set to True to expand the dropdown
|
||||
by default.
|
||||
|
||||
:data: `is_open` is a :class: `~kivy.properties.BooleanProperty`,
|
||||
default to False.
|
||||
'''
|
||||
|
||||
attach_to = ObjectProperty(allownone=True)
|
||||
'''(internal) Property that will be set to the widget on which the drop down
|
||||
list is attached to.
|
||||
|
|
|
@ -116,7 +116,6 @@ class Spinner(Button):
|
|||
def _update_dropdown(self, *largs):
|
||||
dp = self._dropdown
|
||||
cls = self.option_cls
|
||||
|
||||
dp.clear_widgets()
|
||||
for value in self.values:
|
||||
item = cls(text=value)
|
||||
|
@ -124,8 +123,13 @@ class Spinner(Button):
|
|||
dp.add_widget(item)
|
||||
|
||||
def _open_dropdown(self, *largs):
|
||||
self._dropdown.open(self)
|
||||
if not self._dropdown.is_open:
|
||||
self._dropdown.open(self)
|
||||
self._dropdown.is_open = True
|
||||
else:
|
||||
self._dropdown.dismiss()
|
||||
self._dropdown.is_open = False
|
||||
|
||||
def _on_dropdown_select(self, instance, data, *largs):
|
||||
self.text = data
|
||||
|
||||
self._dropdown.is_open = False
|
||||
|
|
Loading…
Reference in New Issue