Skip to content

Commit

Permalink
Merge pull request #132 from ArcaneArts/context-menu-enabled
Browse files Browse the repository at this point in the history
Support enabled property on ContextMenu
  • Loading branch information
sunarya-thito authored Nov 20, 2024
2 parents a85870a + 89cd69f commit d06bd2a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/src/components/menu/context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,15 @@ class ContextMenu extends StatefulWidget {
final List<MenuItem> items;
final HitTestBehavior behavior;
final Axis direction;
final bool enabled;

const ContextMenu({
super.key,
required this.child,
required this.items,
this.behavior = HitTestBehavior.translucent,
this.direction = Axis.vertical,
});
const ContextMenu(
{super.key,
required this.child,
required this.items,
this.behavior = HitTestBehavior.translucent,
this.direction = Axis.vertical,
this.enabled = true});

@override
State<ContextMenu> createState() => _ContextMenuState();
Expand Down Expand Up @@ -454,11 +455,13 @@ class _ContextMenuState extends State<ContextMenu> {
platform == TargetPlatform.fuchsia;
return GestureDetector(
behavior: widget.behavior,
onSecondaryTapDown: (details) {
_showContextMenu(
context, details.globalPosition, _children, widget.direction);
},
onLongPressStart: enableLongPress
onSecondaryTapDown: !widget.enabled
? null
: (details) {
_showContextMenu(
context, details.globalPosition, _children, widget.direction);
},
onLongPressStart: enableLongPress && widget.enabled
? (details) {
_showContextMenu(
context, details.globalPosition, _children, widget.direction);
Expand Down

0 comments on commit d06bd2a

Please sign in to comment.