Skip to content
New issue

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

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

Already on GitHub? # to your account

Add more gestures for TreeViewItem #851

Closed
LinHaoLove opened this issue Jun 1, 2023 · 4 comments
Closed

Add more gestures for TreeViewItem #851

LinHaoLove opened this issue Jun 1, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@LinHaoLove
Copy link

LinHaoLove commented Jun 1, 2023

Is your feature request related to a problem? Please describe.

i need show menu for every treeViewItem on windows and macos,by "onSecondaryTap".
i need show menu for every treeViewItem on android and ios,by "onLongPress" or "other gestures"

Describe the solution you'd like

return TreeView( selectionMode: TreeViewSelectionMode.single, items: [...], onSecondaryTap: (TreeViewItem item, TapDownDetails details,){ print('onSecondaryTap'); }, onLongPress: (TreeViewItem item){ print('onLongPress'); }, onOtherGestures: (TreeViewItem item){ print('Other Gestures'); }, );

@bdlukaa bdlukaa added the enhancement New feature or request label Jun 1, 2023
@LinHaoLove
Copy link
Author

i put a DropDownButton to content of TreeViewItem,and put text widget with gestures to buttonBuilder of DropDownButton.
that is ok!

@WinXaito WinXaito reopened this Jun 12, 2023
@WinXaito
Copy link
Collaborator

I keep this one open, I'm also interested to have a secondary tap on TreeViewIteams.

@bdlukaa
Copy link
Owner

bdlukaa commented Jul 5, 2023

I have designed a concept for this. Each TreeViewItem will have a gestures parameter that will take a <Type, GestureRecognizerFactory> map. In the implementation (_TreeViewItem), a the parameter will be passed into a RawGesturesDetector

To use, it'd be something like:

items: [
  TreeViewItem(
    ...,
    gestures: {
      TapGestureRecognizer: GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
        () => TapGestureRecognizer(),
        (TapGestureRecognizer instance) {
          instance
            ..onTapDown = (details) {}
            ..onSecondaryTap = () {};
        },
      ),
    },
  ),
],

The records:

  • There is no way to add callbacks to every gesture inside TreeViewItem, so this is a viable solution;
  • A gesture recognizer would need to be passed to every TreeViewItem. This means we wouldn't have such thing as TreeView.onSecondaryTap(details, item), that would be invoked for every item;
  • This option is very verbose for the developer, but I think the cases for these are minimum, so we would just provide the necessary callbacks by default (onTap, onSecondaryTap, onLongPress) - with no further customization -, or we can provide this option with GestureRecognizerFactory

@robkri
Copy link
Contributor

robkri commented Jul 6, 2023

This would be a nice feature!

From the point of view of a user, when I see some tree-like element in a desktop app GUI, I would try out these gestures:

  • click
  • double click
  • right click (secondary click)

In a mobile application I would try out:

  • tap
  • long press

Long story short: I think onTap, onDoubleTap, onSecondaryTap and onLongPress should be available by default to cover the most common interactions of a user with a tree view.

@bdlukaa bdlukaa closed this as completed in c77ff17 Jul 7, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants