Skip to content

Commit

Permalink
Feat: Shortcut to clear search bar (#243)
Browse files Browse the repository at this point in the history
* Feat: Shortcut to clear search bar

- Resolves #241

* Refactor: Used a better update mechanism

* Refac: Refactored the test

Co-authored-by: Frederic Sadrieh <[email protected]>
Co-authored-by: Georg Auge <[email protected]>
  • Loading branch information
3 people authored May 19, 2022
1 parent ee881e5 commit 4bb9302
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
initialization
initializeGlobalKeyBindings

KeyBindings := Dictionary newFrom:
{ '<down>' -> [:anEvent :morph | morph selectNext].
'<up>' -> [:anEvent :morph | morph selectPrevious].
'<tab>' -> [:anEvent :morph | morph showChildListOrDoAction: anEvent].
'<tab>' -> [:anEvent :morph | morph showChildListOrDoAction: anEvent].
'<Shift-tab>' -> [:anEvent :morph | morph showParentList].
'<escape>' -> [:anEvent :morph | morph deactivate: anEvent hand].
'<cr>' -> [:anEvent :morph | morph doActionOnSelectedEvent:anEvent] }
'<cr>' -> [:anEvent :morph | morph doActionOnSelectedEvent: anEvent].
'<Ctrl-delete>' -> [:anEvent :morph | morph clearSearchBar: anEvent] }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
events-processing
clearSearchBar: event

self active
ifTrue: [
self query: ''.
self updateItemList.]

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
event handling
grabFocus: hand

hand
newKeyboardFocus: self textField.
newKeyboardFocus: self textField
5 changes: 3 additions & 2 deletions packages/Algernon.package/ALGCore.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"initializeActivationString" : "fsa 6/20/2021 14:10",
"initializeActivationStringForPlatform:" : "fsa 6/26/2021 14:17",
"initializeAlgernon" : "mt 10/20/2015 14:32:03",
"initializeGlobalKeyBindings" : "b 6/21/2021 11:44",
"initializeGlobalKeyBindings" : "fs 5/12/2022 18:41",
"keyBindings" : "J.J. 7/31/2015 20:31",
"maxHalfClickDeviation" : "b 6/16/2021 01:47",
"maximumPerCategory" : "OH 5/12/2021 22:16",
Expand Down Expand Up @@ -57,6 +57,7 @@
"breadcrumbs" : "J.J. 7/16/2015 22:51",
"breadcrumbs:" : "J.J. 7/27/2015 20:20",
"checkWorldBounds" : "rk 6/29/2020 01:09",
"clearSearchBar:" : "fs 5/12/2022 22:36",
"currentItem" : "J.J. 7/30/2015 20:25",
"deactivate" : "topa 3/24/2015 14:11",
"deactivate:" : "jRo 8/5/2020 15:10",
Expand All @@ -66,7 +67,7 @@
"filteringThreshold" : "DS 5/21/2017 16:54",
"firstOnSearchStack" : "jRo 6/14/2020 18:21",
"firstStep:" : "DS 5/21/2017 16:43",
"grabFocus:" : "b 6/2/2021 00:59",
"grabFocus:" : "fs 5/12/2022 18:58",
"handleActivationKeyEvent:" : "NM 6/30/2021 14:43",
"handleAsQuickAccess:" : "NM 6/7/2021 21:22",
"handleListenEvent:" : "NM 6/30/2021 14:45",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
testing
testShortcutToClearSearchBar
| keyboardEvent |
keyboardEvent := ALGFakeKeyboardEvent new keyString: '<Ctrl-delete>'.
self runQuery: 'example string'.
self algInstance keyStroke: keyboardEvent.
self assert: self algInstance query equals: ''


Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
"testNormalKeyStrokesSetsCursorColor" : "NL 6/1/2021 16:32",
"testNumberTriggersItem" : "b 8/5/2021 16:12",
"testScrollingInputField" : "NM 6/1/2021 20:52",
"testSelfFocus" : "NL 6/1/2021 15:27" } }
"testSelfFocus" : "NL 6/1/2021 15:27",
"testShortcutToClearSearchBar" : "fs 5/17/2022 11:42" } }

0 comments on commit 4bb9302

Please sign in to comment.