native_context_menu icon indicating copy to clipboard operation
native_context_menu copied to clipboard

Add support for disabling menu items on macos

Open edwardaux opened this issue 2 years ago • 1 comments

This PR addresses https://github.com/lesnitsky/native_context_menu/issues/11 on macos. A couple of important notes:

  • There's an onSelected function on MenuItem that doesn't seem like it is used at the moment. It was a bit unclear what the difference was designed to be between this callback and onItemSelected in ContextMenuRegion. My assumption is that I'd use the former if I wanted different functions to be called back for each item, and I'd use the latter if I just wanted to have one function (and if both were present, then both would be called). However, as I mentioned, MenuItem.onSelected isn't currently hooked up, so I had to add a call to ContextMenuRegion to make sure it calls both. This assumption may not be correct, but was important for my decision on how to enable/disable each item.
  • I consider adding a separate flag called isEnabled defaulting to true, however, I ended adopting the Flutter convention of disabling the widget if the onSelected function is not set. However, this would be a breaking change for any current users of this library (all menu items would be disabled unless they were setting the onSelected in their MenuItem objects - which they wouldn't be because those callbacks don't currently get called)

Windows and Linux have not been touched.

edwardaux avatar Apr 15 '22 21:04 edwardaux

Thanks I will have a look and and windows and linux support

lesnitsky avatar May 05 '22 13:05 lesnitsky