Skip to content

support onShowPopupMenu on PopupMenuButton #21773

Closed

Description

@zhangjianlin77

add onShowPopupMenu function on PopupMenuButton, the lifecycle of PopupMenu show have "onShow" event

Activity

  1. zoechi commented on Sep 13, 2018

    @zoechi
    Contributor

    What is the use case?
    A popup doesn't show automagically, it only shows when you call showDialog or similar, so you can notify yourself.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 13, 2018
  3. zhangjianlin77 commented on Sep 13, 2018

    @zhangjianlin77
    Author

    What is the use case?
    A popup doesn't show automagically, it only shows when you call showDialog or similar, so you can notify yourself.

    https://github.com/flutter/flutter/blob/d927c9331005f81157fa39dff7b5dab415ad330b/packages/flutter/lib/src/material/popup_menu.dart

    the 'showButtonMenu' function is written in the _PopupMenuButtonState, and I can't know when the PopupMenu is appeared

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 13, 2018
  5. zhangjianlin77 commented on Sep 13, 2018

    @zhangjianlin77
    Author

    What is the use case?
    A popup doesn't show automagically, it only shows when you call showDialog or similar, so you can notify yourself.
    I need to transform the button from '+' to '×' when the button is click

  6. zhangjianlin77 commented on Sep 13, 2018

    @zhangjianlin77
    Author

    Do you mean I call the showMenu to custom my menu?

  7. zoechi commented on Sep 13, 2018

    @zoechi
    Contributor

    Your code somewhere calls showDialog(). This code can notify about the dialog showing.

  8. zhangjianlin77 commented on Sep 13, 2018

    @zhangjianlin77
    Author

    Thanks, Maybe i can use the showMenu, This issue is talk about menu, the dialog cann't calculate the position where to locate
    By the way, I see the PopupMenu is vertical only, Is there common pop widget that can be use to custom my child like PopWindow of android. Maybe I need to write by myself. /(ㄒoㄒ)/~~
    @zanderso

  9. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Sep 25, 2018
  10. added this to the milestone on Sep 25, 2018
  11. egramond commented on Oct 12, 2018

    @egramond
    Contributor

    We also have a use-case that requires the onShowPopupMenu() function: We want to be able to log the activity when the user taps the button to show the menu.

    Currently this isn't possible to check because the showMenu call is burried inside _PopupMenuButtonState.showButtonMenu()

  12. added
    P2Important issues not at the top of the work list
    on May 29, 2020
  13. popiosifcristian commented on Jul 31, 2020

    @popiosifcristian

    Any updates on this issue? I have a case where I need to change the UI if the popup menu is open. Since it does provide onCanceled, it would be nice to have onShow functionality.

  14. eugenioamato commented on Jul 31, 2020

    @eugenioamato

    To achieve this you could fork the material package PopupMenuButton class inside
    flutter/lib/src/material/popup_menu.dart

    to accept one new callback Function
    this.onSelected, this.onCanceled, this.onShowMenu, <----

    then added a new typedef
    typedef PopupMenuShown=void Function(); <------
    declare it as
    final PopupMenuShown onShowMenu;

    then add a call to the callback at the end of showButtonMenu() method
    line 1086:
    widget.onShowMenu();

    after it's possible to add this prop in the creation of the widget
    PopupMenuButton( itemBuilder:..., onSelected: ....., onShowMenu: ...,. <-----

  15. removed this from the milestone on Aug 17, 2020
  16. github-actions commented on Aug 28, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilitycustomer: mulligan (g3)frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions