Add support for disabling menu items on macos #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses #11 on macos. A couple of important notes:
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.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.