Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: input hotkey and delete command fail due to flutter 2.5 upgrade #1096

Merged
merged 1 commit into from Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion kraken/lib/src/dom/elements/input.dart
Expand Up @@ -810,7 +810,7 @@ class InputElement extends Element implements TextInputClient, TickerProvider {
WidgetDelegate? widgetDelegate = ownerDocument.widgetDelegate;

if (_selectionControls == null) {
_selectionOverlay?.hide();
_selectionOverlay?.dispose();
_selectionOverlay = null;
} else if (widgetDelegate != null) {
if (_selectionOverlay == null) {
Expand Down
59 changes: 59 additions & 0 deletions kraken/lib/src/widget/kraken.dart
Expand Up @@ -251,6 +251,15 @@ class _KrakenState extends State<Kraken> with RouteAware {
NextFocusIntent: CallbackAction<NextFocusIntent>(onInvoke: _handleNextFocus),
PreviousFocusIntent: CallbackAction<PreviousFocusIntent>(onInvoke: _handlePreviousFocus),

// Action to delete text.
DeleteTextIntent: CallbackAction<DeleteTextIntent>(onInvoke: _handleDeleteText),

// Action of hot keys control/command + (X, C, V, A).
SelectAllTextIntent: CallbackAction<SelectAllTextIntent>(onInvoke: _handleSelectAllText),
CopySelectionTextIntent: CallbackAction<CopySelectionTextIntent>(onInvoke: _handleCopySelectionText),
CutSelectionTextIntent: CallbackAction<CutSelectionTextIntent>(onInvoke: _handleCutSelectionText),
PasteTextIntent: CallbackAction<PasteTextIntent>(onInvoke: _handlePasteText),

// Action of mouse move hotkeys.
MoveSelectionRightByLineTextIntent: CallbackAction<MoveSelectionRightByLineTextIntent>(onInvoke: _handleMoveSelectionRightByLineText),
MoveSelectionLeftByLineTextIntent: CallbackAction<MoveSelectionLeftByLineTextIntent>(onInvoke: _handleMoveSelectionLeftByLineText),
Expand Down Expand Up @@ -545,6 +554,56 @@ class _KrakenState extends State<Kraken> with RouteAware {
}
}

void _handleDeleteText(DeleteTextIntent intent) {
dom.Element? focusedElement = _findFocusedElement();
if (focusedElement != null) {
RenderEditable? focusedRenderEditable = (focusedElement as dom.InputElement).renderEditable;
if (focusedRenderEditable != null) {
focusedRenderEditable.delete(SelectionChangedCause.keyboard);
}
}
}

void _handleSelectAllText(SelectAllTextIntent intent) {
dom.Element? focusedElement = _findFocusedElement();
if (focusedElement != null) {
RenderEditable? focusedRenderEditable = (focusedElement as dom.InputElement).renderEditable;
if (focusedRenderEditable != null) {
focusedRenderEditable.selectAll(SelectionChangedCause.keyboard);
}
}
}

void _handleCopySelectionText(CopySelectionTextIntent intent) {
dom.Element? focusedElement = _findFocusedElement();
if (focusedElement != null) {
RenderEditable? focusedRenderEditable = (focusedElement as dom.InputElement).renderEditable;
if (focusedRenderEditable != null) {
focusedRenderEditable.copySelection();
}
}
}

void _handleCutSelectionText(CutSelectionTextIntent intent) {
dom.Element? focusedElement = _findFocusedElement();
if (focusedElement != null) {
RenderEditable? focusedRenderEditable = (focusedElement as dom.InputElement).renderEditable;
if (focusedRenderEditable != null) {
focusedRenderEditable.cutSelection(SelectionChangedCause.keyboard);
}
}
}

void _handlePasteText(PasteTextIntent intent) {
dom.Element? focusedElement = _findFocusedElement();
if (focusedElement != null) {
RenderEditable? focusedRenderEditable = (focusedElement as dom.InputElement).renderEditable;
if (focusedRenderEditable != null) {
focusedRenderEditable.pasteText(SelectionChangedCause.keyboard);
}
}
}

void _handleMoveSelectionRightByLineText(MoveSelectionRightByLineTextIntent intent) {
dom.Element? focusedElement = _findFocusedElement();
if (focusedElement != null) {
Expand Down