Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/src/manager/shortcut/pluto_grid_shortcut.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogicalKeyboardKey> filteredKeys;

FilteredHardwareKeyboard(this.filteredKeys);

// Override the HardwareKeyboard logicalKeysPressed to get only the
// filtered keys without NumLock.
@override
Set<LogicalKeyboardKey> get logicalKeysPressed => filteredKeys;
}

/// Class for setting shortcut actions.
///
/// Defaults to [PlutoGridShortcut.defaultActions] if not passing [actions].
Expand Down Expand Up @@ -29,8 +42,17 @@ 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<LogicalKeyboardKey> filteredKeys = state.logicalKeysPressed
.where((key) => key != LogicalKeyboardKey.numLock)
.toSet();
// 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, state)) {
if (action.key.accepts(keyEvent.event, fakeState)) {
action.value.execute(keyEvent: keyEvent, stateManager: stateManager);
return true;
}
Expand Down
10 changes: 9 additions & 1 deletion lib/src/ui/columns/pluto_column_title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ class PlutoColumnTitleState extends PlutoStateWithChange<PlutoColumnTitle> {
),
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);
}
},
),
),
);
Expand Down