Repository: kivy/kivy

Issue:
ActionGroup in spinner mode doesn't close on selection.
If I run run the actionbar.py module directly, executing the "if main" block. The actionbar example loads without error. On my system both of the ActionGroups are displayed in spinner mode due to the available space. If I click an ActionGroup spinner it opens, but selecting an item in the group does not close the dropdown. The only way I have found to close the dropdown it to click elsewhere on the screen.

https://gist.github.com/philwrenn/9121379

There were no errors. I just added the log per the posting instructions. 
## <bountysource-plugin>

Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1421602-actiongroup-in-spinner-mode-doesn-t-close-on-selection?utm_campaign=plugin&utm_content=tracker%2F42681&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F42681&utm_medium=issues&utm_source=github).
</bountysource-plugin>



Discussion:
The issues is that the button's click isn't being mapped to anything. by adding `on_press` events to these, it's easy enough to get expected behavior. The question then becomes whether or not events should be added automatically when a widget is added to an `ActionGroup`. 

Is there ever a case where you would want the popup to remain even after clicking a button (I'm thinking of "pinned" menubars here)? If not, sane defaults might make sense here.

Adding on_press events does not seem to change the behavior of the dropdown.

https://gist.github.com/philwrenn/9130426

I wasn't specific enough, and even used the wrong event. Firstly, it needs to specifically be connected to the ActionGroup's dropdown's select event. Secondly, it should be the on_release button: 

https://gist.github.com/aspidites/9130590

I might have missed something, but it seems there should be a more direct way to get to the underlying dropdown. or perhaps default behavior for a list of widgets should be available (eg. for items that are clickable, the released property should be bound to).

That approach works fine for ActionGroups their mode set to 'spinner'. Things get a little more interesting when accommodating the overflow behavior of buttons directly in an ActionView. 

https://gist.github.com/philwrenn/9135418

Also, since ActionItems in an ActionGroup without an explicit mode may render either way, depending on space, I was thinking you would always want to call select on the ActionGroup's dropdown. The problem is that causes an error if the ActionGroup renders in normal mode.

https://gist.github.com/philwrenn/9135473

While they are both related to each other, neither of them is related to this issue. Please open a separate issue for those. In the meantime I'm looking at what causes the behavior at the moment.

I think what's essentially going on is that if an ActionOverflow doesn't have a parent, the dropdown errors out because it can't properly call `add_widget`. 

Any updates on a successful approach to auto close the dropdown on selection?


Resolving patch:
diff --git a/kivy/uix/actionbar.py b/kivy/uix/actionbar.py
--- a/kivy/uix/actionbar.py
+++ b/kivy/uix/actionbar.py
@@ -15,9 +15,9 @@
 :class:`ContextualActionViews <kivy.uix.actionbar.ContextualActionView>`.
 An :class:`ActionView` will contain an :class:`ActionPrevious` having title,
 app_icon and previous_icon properties. An :class:`ActionView` will contain
-subclasses of :class:`ActionItems <ActionItem>`. Some predefined ones inlcude an
-:class:`ActionButton`, an :class:`ActionToggleButton`, an :class:`ActionCheck`,
-an :class:`ActionSeparator` and an :class:`ActionGroup`.
+subclasses of :class:`ActionItems <ActionItem>`. Some predefined ones inlcude
+an :class:`ActionButton`, an :class:`ActionToggleButton`, an
+:class:`ActionCheck`, an :class:`ActionSeparator` and an :class:`ActionGroup`.
 
 An :class:`ActionGroup` is used to display :class:`ActionItems <ActionItem>`
 in a group. An :class:`ActionView` will always display an :class:`ActionGroup`
@@ -41,8 +41,8 @@
 from kivy.uix.spinner import Spinner
 from kivy.uix.label import Label
 from kivy.config import Config
-from kivy.properties import ObjectProperty, NumericProperty, \
-    BooleanProperty, StringProperty, ListProperty, OptionProperty, AliasProperty
+from kivy.properties import ObjectProperty, NumericProperty, BooleanProperty, \
+    StringProperty, ListProperty, OptionProperty, AliasProperty
 from kivy.metrics import sp
 from kivy.lang import Builder
 from functools import partial
@@ -119,8 +119,8 @@ def get_pack_width(self):
     '''Defines whether the image/icon dispayed on top of the button uses a
     mipmap or not.
 
-    :attr:`mipmap` is a :class:`~kivy.properties.BooleanProperty` and defaults
-    to `True`.
+       :attr:`mipmap` is a :class:`~kivy.properties.BooleanProperty` and
+       defaults to `True`.
     '''
 
 
@@ -180,8 +180,8 @@ class ActionPrevious(BoxLayout, ActionItem):
     color = ListProperty([1, 1, 1, 1])
     '''Text color, in the format (r, g, b, a)
 
-    :attr:`color` is a :class:`~kivy.properties.ListProperty` and defaults to
-    [1, 1, 1, 1].
+       :attr:`color` is a :class:`~kivy.properties.ListProperty` and defaults
+       to [1, 1, 1, 1].
     '''
 
     previous_image = StringProperty(
@@ -259,7 +259,12 @@ class ActionSeparator(ActionItem, Widget):
 class ActionDropDown(DropDown):
     '''ActionDropDown class, see module documentation for more information.
     '''
-    pass
+
+    def on_touch_down(self, touch):
+        if super(ActionDropDown, self).on_touch_down(touch):
+            if self.auto_dismiss:
+                self.dismiss()
+            return True
 
 
 class ActionGroup(ActionItem, Spinner):
@@ -360,8 +365,8 @@ class ActionOverflow(ActionGroup):
         'atlas://data/images/defaulttheme/overflow')
     '''Image to be used as an Overflow Image.
 
-      :attr:`overflow_image` is an :class:`~kivy.properties.ObjectProperty` and
-       defaults to 'atlas://data/images/defaulttheme/overflow'.
+       :attr:`overflow_image` is an :class:`~kivy.properties.ObjectProperty`
+       and defaults to 'atlas://data/images/defaulttheme/overflow'.
     '''
 
     def add_widget(self, action_item, index=0):
@@ -396,22 +401,22 @@ class ActionView(BoxLayout):
     '''Previous button for an ActionView.
 
        :attr:`action_previous` is an :class:`~kivy.properties.ObjectProperty`
-        and defaults to None.
+       and defaults to None.
     '''
 
     background_color = ListProperty([1, 1, 1, 1])
     '''Background color in the format (r, g, b, a).
 
        :attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
-        defaults to [1, 1, 1, 1].
+       defaults to [1, 1, 1, 1].
     '''
 
     background_image = StringProperty(
         'atlas://data/images/defaulttheme/action_view')
     '''Background image of an ActionViews default graphical representation.
 
-      :attr:`background_image` is an :class:`~kivy.properties.StringProperty`
-      and defaults to 'atlas://data/images/defaulttheme/action_view'.
+       :attr:`background_image` is an :class:`~kivy.properties.StringProperty`
+       and defaults to 'atlas://data/images/defaulttheme/action_view'.
     '''
 
     use_separator = BooleanProperty(False)
@@ -643,7 +648,7 @@ class ActionBar(BoxLayout):
     '''Background color, in the format (r, g, b, a).
 
        :attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
-        defaults to [1, 1, 1, 1].
+       defaults to [1, 1, 1, 1].
     '''
 
     background_image = StringProperty(


Test patch: