Skip to content

Commit

Permalink
fixed ToSelectTextFieldBackspaceShortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Oct 18, 2024
1 parent 729d033 commit 218cb52
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 28 deletions.
8 changes: 7 additions & 1 deletion src/Toplo-Widget-Album/ToAlbum.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ ToAlbum >> defaultEditorElement [
^ AlbEditorElement new
]

{ #category : #initialization }
ToAlbum >> defaultEventHandler [

^ ToAlbumEventHandler new
]

{ #category : #initialization }
ToAlbum >> defaultStyler [

Expand Down Expand Up @@ -91,7 +97,7 @@ ToAlbum >> initialize [
self next primarySelectionElementClass: ToAlbumPrimarySelectionElement.
self addChild: self next.
self matchParent.
self addEventHandler: ToAlbumEventHandler new.
self addEventHandler: self defaultEventHandler.
sharedDistributor := BlSharedEventDistributor new.
sharedDistributor
adjustMousePosition: false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ TToSelectInnerContainerElement >> filterTextField: aTextField [
{ #category : #'t - select inner container' }
TToSelectInnerContainerElement >> installFilterTextField [

self filterTextField: ToSelectFilterTextField new.
self filterTextField onInstalledIn: self selectElement.
self filterTextField: self newFilterTextField.
self filterTextField constraintsDo: [ :c |
c linear vertical alignCenter.
c flow vertical alignCenter ].
Expand All @@ -32,6 +31,12 @@ TToSelectInnerContainerElement >> isFiltrable [
^ self selectElement isFiltrable
]

{ #category : #'t - select inner container' }
TToSelectInnerContainerElement >> newFilterTextField [

^ ToSelectFilterTextField new on: self selectElement
]

{ #category : #'t - select inner container' }
TToSelectInnerContainerElement >> onSelectionChangedInPopupListElement: anEvent [

Expand Down
38 changes: 15 additions & 23 deletions src/Toplo-Widget-Select/ToSelectFilterTextField.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ Class {
#name : #ToSelectFilterTextField,
#superclass : #ToTextField,
#instVars : [
'windowPopupHandler',
'selectInnerContainer',
'installedEventHandler'
'selectElement'
],
#category : #'Toplo-Widget-Select-textInput'
#category : #'Toplo-Widget-Select-Filter-TextField'
}

{ #category : #initialization }
ToSelectFilterTextField >> defaultEventHandler [

^ ToSelectFilterTextFieldEventHandler new
]

{ #category : #initialization }
ToSelectFilterTextField >> initialize [

Expand Down Expand Up @@ -38,22 +42,13 @@ ToSelectFilterTextField >> nodeBeforeDo: aBlock [
]

{ #category : #'api - hooks' }
ToSelectFilterTextField >> onInstalledIn: aSelectElement [
ToSelectFilterTextField >> on: aSelectElement [

selectInnerContainer := aSelectElement innerContainer.
| windowPopupHandler |
selectElement := aSelectElement.
self withoutLineWrapping.
self id: #filterTextField.
self selectFiltrable: aSelectElement isFiltrable.
installedEventHandler := {
(BlEventHandler
on: AlbTextEditedEvent
do: [ :event |
aSelectElement filterStringChanged ]).
(BlEventHandler
on: AlbTextReplacedEvent
do: [ :event |
aSelectElement filterStringChanged ]) }.
installedEventHandler do: [ :h | self addEventHandler: h ].

self hFitContent.

Expand All @@ -72,13 +67,10 @@ ToSelectFilterTextField >> onInstalledIn: aSelectElement [
self infinite addEventHandler: windowPopupHandler
]

{ #category : #'api - hooks' }
ToSelectFilterTextField >> onUninstalledIn: aSelectElement [
{ #category : #accessing }
ToSelectFilterTextField >> selectElement [

installedEventHandler do: [ :h | self removeEventHandler: h ].
installedEventHandler := #( ).
self infinite removeEventHandler: windowPopupHandler.
windowPopupHandler := nil
^ selectElement
]

{ #category : #accessing }
Expand All @@ -96,7 +88,7 @@ ToSelectFilterTextField >> selectFiltrable: aBoolean [
{ #category : #accessing }
ToSelectFilterTextField >> selectNodeBefore [

^ selectInnerContainer nodes
^ selectElement innerContainer nodes
ifEmpty: [ ]
ifNotEmpty: [ :nodes | nodes last ]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Class {
#name : #ToSelectFilterTextFieldEventHandler,
#superclass : #ToAlbumEventHandler,
#category : #'Toplo-Widget-Select-Filter-TextField'
}

{ #category : #'api - accessing' }
ToSelectFilterTextFieldEventHandler >> eventsToHandle [

^ super eventsToHandle , { AlbTextEditedEvent. AlbTextReplacedEvent }
]

{ #category : #'event handling' }
ToSelectFilterTextFieldEventHandler >> textEditedEvent: anEvent [

anEvent currentTarget selectElement filterStringChanged
]

{ #category : #'event handling' }
ToSelectFilterTextFieldEventHandler >> textReplacedEvent: anEvent [

anEvent currentTarget selectElement filterStringChanged
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #ToSelectFilterTextFieldSkin,
#superclass : #ToAlbumSkin,
#category : #'Toplo-Widget-Select-textInput'
#category : #'Toplo-Widget-Select-Filter-TextField'
}

{ #category : #accessing }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #ToSelectTextFieldBackspaceShortcut,
#superclass : #AlbEditorDeleteOneLetterBeforeCursorShortcut,
#category : #'Toplo-Widget-Select-textInput'
#category : #'Toplo-Widget-Select-Filter-TextField'
}

{ #category : #evaluation }
Expand Down

0 comments on commit 218cb52

Please sign in to comment.