From 6012c68feae1a405ab9c3da05340a783f3ff0d6f Mon Sep 17 00:00:00 2001 From: itsnotmeman Date: Fri, 7 Mar 2025 09:00:52 +0100 Subject: [PATCH 1/4] itsnotmeman, branch develop v1: Added the feature to toggle sorting a column by clicking on the icon next to the column title. Fixes issue #96. --- lib/src/ui/columns/pluto_column_title.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/columns/pluto_column_title.dart b/lib/src/ui/columns/pluto_column_title.dart index 79f75573b..8c5ef5ab7 100644 --- a/lib/src/ui/columns/pluto_column_title.dart +++ b/lib/src/ui/columns/pluto_column_title.dart @@ -152,7 +152,15 @@ class PlutoColumnTitleState extends PlutoStateWithChange { ), iconSize: style.iconSize, mouseCursor: contextMenuCursor, - onPressed: null, + hoverColor: Colors.transparent, + splashColor: Colors.transparent, + highlightColor: Colors.transparent, + onPressed: () { + if (mounted && widget.column.enableSorting && + !widget.column.enableContextMenu) { + stateManager.toggleSortColumn(widget.column); + } + }, ), ), ); From 57c0b82dfe14581975e0f4cbb87f7d6f90271f67 Mon Sep 17 00:00:00 2001 From: Author itsnotmeman Date: Fri, 22 Nov 2024 13:12:46 +0100 Subject: [PATCH 2/4] itsnotmeman v1: Introduced a new null check to prevent the 'Null check operator used on a null value' exception. --- lib/src/manager/shortcut/pluto_grid_shortcut_action.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart b/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart index 2e5f2364e..e2284058a 100644 --- a/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart +++ b/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart @@ -658,6 +658,9 @@ class PlutoGridActionPasteValues extends PlutoGridShortcutAction { } Clipboard.getData('text/plain').then((value) { + if (value == null) { + return; + } List> textList = PlutoClipboardTransformation.stringToList(value!.text!); From cd36bd39081c328a8fbd8960ee0744a68f084c88 Mon Sep 17 00:00:00 2001 From: itsnotmeman Date: Tue, 11 Mar 2025 10:04:45 +0100 Subject: [PATCH 3/4] branch develop v2: Added a new HardwareKeyboard instance which ignores the numLock key so that shortcuts and arrows always work in the PlutoGrid on Linux. --- lib/src/manager/shortcut/pluto_grid_shortcut.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/manager/shortcut/pluto_grid_shortcut.dart b/lib/src/manager/shortcut/pluto_grid_shortcut.dart index e926e34a2..6872a800b 100644 --- a/lib/src/manager/shortcut/pluto_grid_shortcut.dart +++ b/lib/src/manager/shortcut/pluto_grid_shortcut.dart @@ -29,8 +29,18 @@ class PlutoGridShortcut { required PlutoGridStateManager stateManager, required HardwareKeyboard state, }) { + // Remove NumLock before checking shortcuts. This will enable the arrow + // keys and shortcuts to work correctly on Linux too. + final Set filteredKeys = state.logicalKeysPressed + .where((key) => key != LogicalKeyboardKey.numLock) + .toSet(); + // Create a fake state object with filtered keys. + final HardwareKeyboard fakeState = HardwareKeyboard.instance; + fakeState.logicalKeysPressed.clear(); + fakeState.logicalKeysPressed.addAll(filteredKeys); + for (final action in actions.entries) { - if (action.key.accepts(keyEvent.event, state)) { + if (action.key.accepts(keyEvent.event, fakeState)) { action.value.execute(keyEvent: keyEvent, stateManager: stateManager); return true; } From c036c550fc6722aee3fb076156cb22d5c6f9e35c Mon Sep 17 00:00:00 2001 From: itsnotmeman Date: Tue, 11 Mar 2025 11:01:03 +0100 Subject: [PATCH 4/4] branch my_main v1: Fixes the last merge 'Merge branch develop into my_main' because the solution did not work. --- .../manager/shortcut/pluto_grid_shortcut.dart | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/src/manager/shortcut/pluto_grid_shortcut.dart b/lib/src/manager/shortcut/pluto_grid_shortcut.dart index 6872a800b..c5d660699 100644 --- a/lib/src/manager/shortcut/pluto_grid_shortcut.dart +++ b/lib/src/manager/shortcut/pluto_grid_shortcut.dart @@ -2,6 +2,19 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:pluto_grid_plus/pluto_grid_plus.dart'; +// Create a custom wrapper that filters out NumLock. +// This will enable the arrow keys and shortcuts to work correctly on Linux too. +class FilteredHardwareKeyboard extends HardwareKeyboard { + final Set filteredKeys; + + FilteredHardwareKeyboard(this.filteredKeys); + + // Override the HardwareKeyboard logicalKeysPressed to get only the + // filtered keys without NumLock. + @override + Set get logicalKeysPressed => filteredKeys; +} + /// Class for setting shortcut actions. /// /// Defaults to [PlutoGridShortcut.defaultActions] if not passing [actions]. @@ -34,10 +47,9 @@ class PlutoGridShortcut { final Set filteredKeys = state.logicalKeysPressed .where((key) => key != LogicalKeyboardKey.numLock) .toSet(); - // Create a fake state object with filtered keys. - final HardwareKeyboard fakeState = HardwareKeyboard.instance; - fakeState.logicalKeysPressed.clear(); - fakeState.logicalKeysPressed.addAll(filteredKeys); + // Create a wrapper around the HardwareKeyboard instance with filtered keys. + final FilteredHardwareKeyboard fakeState = + FilteredHardwareKeyboard(filteredKeys); for (final action in actions.entries) { if (action.key.accepts(keyEvent.event, fakeState)) {