Skip to content

Commit

Permalink
Merge pull request #2 from phntmxyz/disable-keymanager
Browse files Browse the repository at this point in the history
Disable keymanager
  • Loading branch information
jxstxn1 authored May 31, 2023
2 parents fbb27ef + bee88fc commit c2c8fd2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The original package can be found here: https://pub.dev/packages/pluto_grid.
## Changes we made
- Improve the adaptability of the column title - https://github.com/bosskmk/pluto_grid/pull/811
- Customize the cell border color - https://github.com/bosskmk/pluto_grid/pull/810
- Be able to disable the internal Key Manager

## NOTE
Whenever the original library is updated, we need to update this as well.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/pluto_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ class PlutoGridState extends PlutoStateWithChange<PlutoGrid> {
Widget build(BuildContext context) {
return FocusScope(
onFocusChange: _stateManager.setKeepFocus,
onKey: _handleGridFocusOnKey,
onKey: widget.configuration.useKeyManager ? _handleGridFocusOnKey : null,
child: _GridContainer(
stateManager: _stateManager,
child: LayoutBuilder(
Expand Down
9 changes: 9 additions & 0 deletions lib/src/pluto_grid_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class PlutoGridConfiguration {
/// Moves the current cell when focus reaches the left or right edge in the edit state.
final bool enableMoveHorizontalInEditing;

/// Disables/enables the PlutoGrid Key Manager which is intercepting any key event.
final bool useKeyManager;

/// [PlutoEnterKeyAction.EditingAndMoveDown]
/// It switches to the editing state, and moves down in the editing state.
///
Expand Down Expand Up @@ -76,6 +79,7 @@ class PlutoGridConfiguration {
const PlutoGridConfiguration({
this.enableMoveDownAfterSelecting = false,
this.enableMoveHorizontalInEditing = false,
this.useKeyManager = true,
this.enterKeyAction = PlutoGridEnterKeyAction.editingAndMoveDown,
this.tabKeyAction = PlutoGridTabKeyAction.normal,
this.shortcut = const PlutoGridShortcut(),
Expand All @@ -89,6 +93,7 @@ class PlutoGridConfiguration {
const PlutoGridConfiguration.dark({
this.enableMoveDownAfterSelecting = false,
this.enableMoveHorizontalInEditing = false,
this.useKeyManager = true,
this.enterKeyAction = PlutoGridEnterKeyAction.editingAndMoveDown,
this.tabKeyAction = PlutoGridTabKeyAction.normal,
this.shortcut = const PlutoGridShortcut(),
Expand Down Expand Up @@ -131,6 +136,7 @@ class PlutoGridConfiguration {
PlutoGridConfiguration copyWith({
bool? enableMoveDownAfterSelecting,
bool? enableMoveHorizontalInEditing,
bool? useKeyManager,
PlutoGridEnterKeyAction? enterKeyAction,
PlutoGridTabKeyAction? tabKeyAction,
PlutoGridShortcut? shortcut,
Expand All @@ -145,6 +151,7 @@ class PlutoGridConfiguration {
enableMoveDownAfterSelecting ?? this.enableMoveDownAfterSelecting,
enableMoveHorizontalInEditing:
enableMoveHorizontalInEditing ?? this.enableMoveHorizontalInEditing,
useKeyManager: useKeyManager ?? this.useKeyManager,
enterKeyAction: enterKeyAction ?? this.enterKeyAction,
tabKeyAction: tabKeyAction ?? this.tabKeyAction,
shortcut: shortcut ?? this.shortcut,
Expand All @@ -165,6 +172,7 @@ class PlutoGridConfiguration {
other.enableMoveDownAfterSelecting &&
enableMoveHorizontalInEditing ==
other.enableMoveHorizontalInEditing &&
useKeyManager == other.useKeyManager &&
enterKeyAction == other.enterKeyAction &&
tabKeyAction == other.tabKeyAction &&
shortcut == other.shortcut &&
Expand All @@ -179,6 +187,7 @@ class PlutoGridConfiguration {
int get hashCode => Object.hash(
enableMoveDownAfterSelecting,
enableMoveHorizontalInEditing,
useKeyManager,
enterKeyAction,
tabKeyAction,
shortcut,
Expand Down

0 comments on commit c2c8fd2

Please sign in to comment.