native_context_menu
native_context_menu copied to clipboard
Add support for disabling menu items on macos
This PR addresses https://github.com/lesnitsky/native_context_menu/issues/11 on macos. A couple of important notes:
- There's an
onSelected
function onMenuItem
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 andonItemSelected
inContextMenuRegion
. 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 toContextMenuRegion
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 totrue
, however, I ended adopting the Flutter convention of disabling the widget if theonSelected
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 theonSelected
in theirMenuItem
objects - which they wouldn't be because those callbacks don't currently get called)
Windows and Linux have not been touched.
Thanks I will have a look and and windows and linux support