浏览代码

add global control event handler to editable

/main
xingwei.zhu 5 年前
当前提交
58b8cb14
共有 2 个文件被更改,包括 25 次插入6 次删除
  1. 14
      Runtime/rendering/editable.cs
  2. 17
      Runtime/widgets/editable_text.cs

14
Runtime/rendering/editable.cs


using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;

float devicePixelRatio = 1.0f,
bool? enableInteractiveSelection = null,
EdgeInsets floatingCursorAddedMargin = null,
TextSelectionDelegate textSelectionDelegate = null) {
TextSelectionDelegate textSelectionDelegate = null,
Func<RawKeyEvent, bool> globalKeyEventHandler = null) {
floatingCursorAddedMargin = floatingCursorAddedMargin ?? EdgeInsets.fromLTRB(4, 4, 4, 5);
D.assert(textSelectionDelegate != null);
D.assert(minLines == null || minLines > 0);

this.onCaretChanged = onCaretChanged;
this.onSelectionChanged = onSelectionChanged;
this.textSelectionDelegate = textSelectionDelegate;
this.globalKeyEventHandler = globalKeyEventHandler;
D.assert(this._maxLines == null || this._maxLines > 0);
D.assert(this._showCursor != null);

bool _resetCursor = false;
public Func<RawKeyEvent, bool> globalKeyEventHandler;
if (this.globalKeyEventHandler != null &&
this.globalKeyEventHandler.Invoke(keyEvent)) {
return;
}
if (keyEvent is RawKeyUpEvent) {
return;
}

17
Runtime/widgets/editable_text.cs


Brightness? keyboardAppearance = Brightness.light,
DragStartBehavior dragStartBehavior = DragStartBehavior.down,
bool? enableInteractiveSelection = null,
ScrollPhysics scrollPhysics = null
ScrollPhysics scrollPhysics = null,
Func<RawKeyEvent, bool> globalCtrlKeyEventHandler = null
) : base(key) {
D.assert(controller != null);
D.assert(focusNode != null);

this.enableInteractiveSelection = enableInteractiveSelection;
this.dragStartBehavior = dragStartBehavior;
this.scrollPhysics = scrollPhysics;
this.globalKeyEventHandler = globalCtrlKeyEventHandler;
}
public readonly TextEditingController controller;

public readonly DragStartBehavior dragStartBehavior;
public readonly bool? enableInteractiveSelection;
public readonly ScrollPhysics scrollPhysics;
public readonly Func<RawKeyEvent, bool> globalKeyEventHandler;
public bool selectionEnabled {
get { return this.enableInteractiveSelection ?? !this.obscureText; }

paintCursorAboveText: this.widget.paintCursorAboveText,
enableInteractiveSelection: this.widget.enableInteractiveSelection == true,
textSelectionDelegate: this,
devicePixelRatio: this._devicePixelRatio
devicePixelRatio: this._devicePixelRatio,
globalKeyEventHandler: this.widget.globalKeyEventHandler
)
)
);

public readonly TextSelectionDelegate textSelectionDelegate;
public readonly bool? paintCursorAboveText;
public readonly float? devicePixelRatio;
public readonly Func<RawKeyEvent, bool> globalKeyEventHandler;
public _Editable(TextSpan textSpan = null,

Offset cursorOffset = null,
bool enableInteractiveSelection = true,
bool? paintCursorAboveText = null,
float? devicePixelRatio = null) : base(key) {
float? devicePixelRatio = null,
Func<RawKeyEvent, bool> globalKeyEventHandler = null) : base(key) {
this.textSpan = textSpan;
this.value = value;
this.cursorColor = cursorColor;

this.enableInteractiveSelection = enableInteractiveSelection;
this.paintCursorAboveText = paintCursorAboveText;
this.devicePixelRatio = devicePixelRatio;
this.globalKeyEventHandler = globalKeyEventHandler;
}
public override RenderObject createRenderObject(BuildContext context) {

enableInteractiveSelection: this.enableInteractiveSelection,
textSelectionDelegate: this.textSelectionDelegate,
paintCursorAboveText: this.paintCursorAboveText == true,
devicePixelRatio: this.devicePixelRatio ?? 1.0f
devicePixelRatio: this.devicePixelRatio ?? 1.0f,
globalKeyEventHandler: this.globalKeyEventHandler
);
}

edit.enableInteractiveSelection = this.enableInteractiveSelection;
edit.paintCursorAboveText = this.paintCursorAboveText == true;
edit.devicePixelRatio = this.devicePixelRatio ?? 1.0f;
edit.globalKeyEventHandler = this.globalKeyEventHandler;
}
}
}
正在加载...
取消
保存