From 04ce4a07cfa0a6163a7c52d54407f5bbceaf67f9 Mon Sep 17 00:00:00 2001 From: Cierra_Runis <2864283875@qq.com> Date: Sat, 18 May 2024 00:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8DAdd=20`readOnlyMouseCursor`=20to=20?= =?UTF-8?q?config=20mouse=20cursor=20type=20Related=20issue:=20[Bug]=20Mou?= =?UTF-8?q?se=20cursor=20is=20still=20text=20insertion=20type=20when=20`re?= =?UTF-8?q?adOnly`=20is=20`false`=20#1752?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/raw_editor/raw_editor_configurations.dart | 6 +++++- .../widgets/raw_editor/raw_editor_render_object.dart | 5 +++-- lib/src/widgets/raw_editor/raw_editor_state.dart | 12 ++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/src/models/config/raw_editor/raw_editor_configurations.dart b/lib/src/models/config/raw_editor/raw_editor_configurations.dart index eb1f9def..f6cc9cf2 100644 --- a/lib/src/models/config/raw_editor/raw_editor_configurations.dart +++ b/lib/src/models/config/raw_editor/raw_editor_configurations.dart @@ -22,7 +22,8 @@ import 'package:flutter/widgets.dart' TextFieldTapRegion, TextSelectionControls, ValueChanged, - Widget; + Widget, + MouseCursor; import 'package:meta/meta.dart' show immutable; import '../../../widgets/others/cursor.dart'; @@ -174,6 +175,9 @@ class QuillRawEditorConfigurations extends Equatable { /// The style to be used for the editing cursor. final CursorStyle cursorStyle; + /// The [readOnlyMouseCursor] is used for Windows, macOS when [readOnly] is [true] + final MouseCursor readOnlyMouseCursor = SystemMouseCursors.text; + /// Configures how the platform keyboard will select an uppercase or /// lowercase keyboard. /// diff --git a/lib/src/widgets/raw_editor/raw_editor_render_object.dart b/lib/src/widgets/raw_editor/raw_editor_render_object.dart index af99671f..ec9fb2cd 100644 --- a/lib/src/widgets/raw_editor/raw_editor_render_object.dart +++ b/lib/src/widgets/raw_editor/raw_editor_render_object.dart @@ -5,8 +5,9 @@ import '../../models/documents/document.dart'; import '../editor/editor.dart'; import '../others/cursor.dart'; -class QuilRawEditorMultiChildRenderObject extends MultiChildRenderObjectWidget { - const QuilRawEditorMultiChildRenderObject({ +class QuillRawEditorMultiChildRenderObject + extends MultiChildRenderObjectWidget { + const QuillRawEditorMultiChildRenderObject({ required super.children, required this.document, required this.textDirection, diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index e452f4fd..07e5f013 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -483,8 +483,10 @@ class QuillRawEditorState extends EditorState viewportBuilder: (_, offset) => CompositedTransformTarget( link: _toolbarLayerLink, child: MouseRegion( - cursor: SystemMouseCursors.text, - child: QuilRawEditorMultiChildRenderObject( + cursor: widget.configurations.readOnly + ? widget.configurations.readOnlyMouseCursor + : SystemMouseCursors.text, + child: QuillRawEditorMultiChildRenderObject( key: _editorKey, offset: offset, document: doc, @@ -515,8 +517,10 @@ class QuillRawEditorState extends EditorState link: _toolbarLayerLink, child: Semantics( child: MouseRegion( - cursor: SystemMouseCursors.text, - child: QuilRawEditorMultiChildRenderObject( + cursor: widget.configurations.readOnly + ? widget.configurations.readOnlyMouseCursor + : SystemMouseCursors.text, + child: QuillRawEditorMultiChildRenderObject( key: _editorKey, document: doc, selection: controller.selection,