-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Use case
When writing MacOS applications, one is forced to use PlatformMenuBar and related classes to interact with the native MacOS menu system.
PlatformMenuBar's PlatformMenuItem class has no way to specify a tooltip for menu items . This is extremely common on MacOS (e.g. the "Open Recent" menu items in BBEdit, etc).
Both native MacOS and the for-Windows-platform MenuBar widget allow addition of tooltips to menu items.
Thus Mac platform flutter applications lack a capability that both flutter-on-windows and native-macos applications have.
Windows
The Windows alternative to PlatformMenuBar, the flutter SDK MenuBar widget, allows easy addition of tooltips for menus using a Tooltip widget:
MenuItemButton(
child: Tooltip(
message: 'Open an existing file',
child: Text('Open'),
),
Native MacOS
In native MacOS, tooltips can be added easily by using the .toolTip property of NSMenuItem as documented at: https://developer.apple.com/documentation/appkit/nsmenuitem
Flutter-on-MacOS
No capability exists to specify a tooltip for a menu item. See: https://api.flutter.dev/flutter/widgets/PlatformMenuItem-class.html
Only a String .label can be set.
Proposal
Feature parity with flutter-on-windows and native-macos could be accomplished by:
- adding a
.toolTipparameter to flutter'sPlatformMenuItemwidget - including that parameter in the serialization of data to pass through the native bridge
- including that parameter in de-serialization of data in macOS native code
- applying the parameter when creating
NSMenuIteminstances
PlatformMenuBar uses the MacOS NSMenuItem class directly for actual native implementation. (See: https://github.com/flutter/flutter/blob/master/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPlugin.mm)
NSMenuItem already accepts an optional string for .toolTip (which flutter does not use).
All the pieces are there, it just needs an expansion of the parameter set from Dart code through to the NSMenuItem object instantiation.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status