Conversation
| Offset? _lastTapDownPosition; | ||
|
|
||
| /// The position of the most recent tap down event on this text input. | ||
| Offset? get lastTapDownPosition => _lastTapDownPosition; |
There was a problem hiding this comment.
I had to expose this in order to position the menu at the tap position (on mobile, it's positioned centered on the selection). Any objections to this or better ideas?
Ideally I'll be able to clean up RenderEditable stuff like this in my refactor later...
There was a problem hiding this comment.
Probably OK in the short term. We should really be using the existing menu system to show desktop menus.
a3b723d to
343c2ec
Compare
| const double _kToolbarWidth = 222.0; | ||
| const Color _kToolbarBorderColor = Color(0xFF505152); | ||
| const Radius _kToolbarBorderRadius = Radius.circular(4.0); | ||
| const Color _kToolbarBackgroundColor = Color(0xFF2D2E31); |
There was a problem hiding this comment.
How do I get this from the theme so that it depends on light/dark mode?
There was a problem hiding this comment.
CupertinoDynamicColor values in CupertinoColors resolve to different color values, depending on the theme's CupertinoTheme's brightness. CupertinoDynamicColor.resolve(CupertinoColors.systemBlue, context).
| child: CupertinoButton( | ||
| alignment: Alignment.centerLeft, | ||
| borderRadius: null, | ||
| color: _isHovered ? CupertinoTheme.of(context).primaryColor : null, | ||
| minSize: 0.0, | ||
| onPressed: widget.onPressed, | ||
| padding: _kToolbarButtonPadding, | ||
| pressedOpacity: 0.7, | ||
| child: widget.child, | ||
| ), |
There was a problem hiding this comment.
It's not, although we could improve the situation a little by tweaking the padding for now. Part of the root problem is #72521 (comment)
There was a problem hiding this comment.
I've improved it by a pixel or two with padding and it looks noticeably better.
|
|
||
| // These values were measured from a screenshot of TextEdit on MacOS 10.15.7 on | ||
| // a Macbook Pro. | ||
| const double _kToolbarWidth = 222.0; |
There was a problem hiding this comment.
Hello Justin !
It seems that the width is not fixed and depends on the widest menu item according to Apple documentation.
There was a problem hiding this comment.
Good point, thanks! I'll make that a minimum width.
There was a problem hiding this comment.
This is not as easy as I thought. I think it might need a custom layout widget. The parent needs to size itself to the biggest intrinsic width of its children, and the children then need to all match that.
I've added this to the "Known limitations" above since this PR is somewhat rushed. Given more time this is definitely doable, though.
| /// * [TextSelectionToolbar.toolbarBuilder], which is of this type. | ||
| /// * [CupertinoTextSelectionToolbar.toolbarBuilder], which is similar, but | ||
| /// for a Cupertino-style toolbar. | ||
| typedef ToolbarBuilder = Widget Function(BuildContext context, Widget child); |
There was a problem hiding this comment.
Moved to widgets so it can be shared.
|
The Google testing failure is just because #73900, which this PR depends on, has not yet been rolled into google3. |
43eebd8 to
1dbb384
Compare
|
This pull request is not suitable for automatic merging in its current state.
|
|
I'm going to merge this even though Google tests are failing because:
CC @HansMuller |
| List<TextSelectionPoint> endpoints, | ||
| TextSelectionDelegate delegate, | ||
| ClipboardStatusNotifier clipboardStatus, | ||
| Offset? lastSecondaryTapDownPosition, |
There was a problem hiding this comment.
@justinmc This is a breaking change.
What is the suggested migration?
There was a problem hiding this comment.
(this breaks flutter_math e.g. - I will link the PR)
There was a problem hiding this comment.
Ah sorry about that. The migration should be to pass renderObject.lastSecondaryTapDownPosition. See https://github.com/flutter/flutter/pull/73882/files#diff-6f186b82dcb3d864ea23246744ea7a67bcb64d369e0da5495cd0bd0e038f9bd9R600
There was a problem hiding this comment.
Alright, thanks ❤️


A minimal Mac context menu.
Native is left, Flutter is right.

Tests
Breaking change
No.
Known limitations
I'm tracking all of these in #74255.
However, it is possible to customize the buttons with a little work (similar to how it is on Android/iOS now).Disallowing customization until the menu is done in a more robust way.