Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add extra mouse callbacks for TabView's Tab #1138

Closed
diluculo opened this issue Nov 18, 2024 · 2 comments
Closed

[Feature Request] Add extra mouse callbacks for TabView's Tab #1138

diluculo opened this issue Nov 18, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@diluculo
Copy link
Contributor

Add built-in context flyout support to Tab items in TabView to provide quick access to tab operations.

image

Example Usage

Tab(
  text: const Text('Tab 1'),
  body: Container(),
  flyoutItems: [
    FlyoutMenuItem(
      text: const Text('Close'),
      onPressed: onClosed,
    ),
    FlyoutMenuItem(
      text: const Text('Close Others'),
      onPressed: () {
        // Handle close others
      },
    ),
    FlyoutMenuItem(
      text: const Text('Rename'),
      onPressed: () {
        // Handle rename
      },
    ),
  ],
  onClosed: () {
    // Handle tab close
  },
)
@diluculo
Copy link
Contributor Author

I'm uncertain about the standard approach for handling context menus in Flutter. Perhaps using GestureDetector.onSecondaryTapUp for desktop app and onLongPress for web app might work.

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 19, 2024

Unfortunately we do not implement extra features that are not present in the native implementation. On the native TabView, this isn't implemented by default - and is always implemented by the software itself. Each browser has its own Flyout implementation on the tabs.

We currently do not expose the onSecondaryTap and onLongPress callbacks for the Tab widget, but it can be easily added by extending the Tab class and creating your own tab implementation.

final MyCustomTab extends Tab {

  MyCustomTab({
    super.key,
    required super.body,
    required super.text,
  });
  
  @override
  State<Tab> createState() => MyCustomTabState();

}

class MyCustomTabState extends TabState {

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onSecondaryTap: () { ... },
      onLongPress: () { ... },
      child: super.build(context),
    );
  }

}

I am making this a request to add extra action callbacks to the Tab widget. A pull-request would be highly appreciated.

@bdlukaa bdlukaa changed the title Add Context Flyout to Tab items in TabView [Feature Request] Add extra mouse callbacks for TabView's Tab Nov 19, 2024
@bdlukaa bdlukaa added the enhancement New feature or request label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants