Question

Iwant to have a drop-down menu in my ActionBar.

An actiongroup in a spinner mode does what I want to have.

The only problem with this solution is that ActionButtons need to be double-clicked (or longer-clicked) inside the Actiongroup, while outside of it they could be single-clicked. I would like to use singleclicks.

Could anyone help me with this?

Using: Python 3.4 ; Kivy 1.8.0; Win 7

    #menu-line on the top
ActionBar:
    size_hint: 1, None
    ActionView:
        use_separator: True
        ActionPrevious:
            title: 'title'
            with_previous: False
            disabled: True
        ActionButton:
            text: 'button'
        ActionGroup:
            mode: 'spinner'
            text: 'Languages'
            ActionButton:
                text: 'German'
                on_press: root.do_something()
            ActionButton:
                text: 'English'
                on_release: root.do_something()
Was it helpful?

Solution

warning: The answer isn't pretty.

If you follow this issue, you'll see that the problem is that ActionButtons event's aren't mapped. The solution involves giving the ActionGroup an id so that it can be referenced, changing the mode to spinner(which you've already done), and connecting the ActionGroup._dropdowns select event to your callback:

#menu-line on the top
ActionBar:
    size_hint: 1, None
    ActionView:
        use_separator: True
        ActionPrevious:
            title: 'title'
            with_previous: False
            disabled: True
        ActionButton:
            text: 'button'
        ActionGroup:
            id: action_group
            mode: 'spinner'
            text: 'Languages'
            ActionButton:
                text: 'German'
                on_release: action_group._dropdown.select(root.do_something())
            ActionButton:
                text: 'English'
                on_release: action_group._dropdown.select(root.do_something())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top