diff --git a/src/Toplo-Widget-Album/ToAlbum.class.st b/src/Toplo-Widget-Album/ToAlbum.class.st index 7b1dffbc..7687a308 100644 --- a/src/Toplo-Widget-Album/ToAlbum.class.st +++ b/src/Toplo-Widget-Album/ToAlbum.class.st @@ -49,6 +49,12 @@ ToAlbum >> defaultEditorElement [ ^ AlbEditorElement new ] +{ #category : #initialization } +ToAlbum >> defaultEventHandler [ + + ^ ToAlbumEventHandler new +] + { #category : #initialization } ToAlbum >> defaultStyler [ @@ -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; diff --git a/src/Toplo-Widget-Select/TToSelectInnerContainerElement.trait.st b/src/Toplo-Widget-Select/TToSelectInnerContainerElement.trait.st index 861a7eac..4e229776 100644 --- a/src/Toplo-Widget-Select/TToSelectInnerContainerElement.trait.st +++ b/src/Toplo-Widget-Select/TToSelectInnerContainerElement.trait.st @@ -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 ]. @@ -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 [ diff --git a/src/Toplo-Widget-Select/ToSelectFilterTextField.class.st b/src/Toplo-Widget-Select/ToSelectFilterTextField.class.st index 9a53745e..7602cb04 100644 --- a/src/Toplo-Widget-Select/ToSelectFilterTextField.class.st +++ b/src/Toplo-Widget-Select/ToSelectFilterTextField.class.st @@ -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 [ @@ -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. @@ -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 } @@ -96,7 +88,7 @@ ToSelectFilterTextField >> selectFiltrable: aBoolean [ { #category : #accessing } ToSelectFilterTextField >> selectNodeBefore [ - ^ selectInnerContainer nodes + ^ selectElement innerContainer nodes ifEmpty: [ ] ifNotEmpty: [ :nodes | nodes last ] ] diff --git a/src/Toplo-Widget-Select/ToSelectFilterTextFieldEventHandler.class.st b/src/Toplo-Widget-Select/ToSelectFilterTextFieldEventHandler.class.st new file mode 100644 index 00000000..6e226af6 --- /dev/null +++ b/src/Toplo-Widget-Select/ToSelectFilterTextFieldEventHandler.class.st @@ -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 +] diff --git a/src/Toplo-Widget-Select/ToSelectFilterTextFieldSkin.class.st b/src/Toplo-Widget-Select/ToSelectFilterTextFieldSkin.class.st index 91b90cd8..05078439 100644 --- a/src/Toplo-Widget-Select/ToSelectFilterTextFieldSkin.class.st +++ b/src/Toplo-Widget-Select/ToSelectFilterTextFieldSkin.class.st @@ -1,7 +1,7 @@ Class { #name : #ToSelectFilterTextFieldSkin, #superclass : #ToAlbumSkin, - #category : #'Toplo-Widget-Select-textInput' + #category : #'Toplo-Widget-Select-Filter-TextField' } { #category : #accessing } diff --git a/src/Toplo-Widget-Select/ToSelectTextFieldBackspaceShortcut.class.st b/src/Toplo-Widget-Select/ToSelectTextFieldBackspaceShortcut.class.st index 8e743d14..4f6028b0 100644 --- a/src/Toplo-Widget-Select/ToSelectTextFieldBackspaceShortcut.class.st +++ b/src/Toplo-Widget-Select/ToSelectTextFieldBackspaceShortcut.class.st @@ -1,7 +1,7 @@ Class { #name : #ToSelectTextFieldBackspaceShortcut, #superclass : #AlbEditorDeleteOneLetterBeforeCursorShortcut, - #category : #'Toplo-Widget-Select-textInput' + #category : #'Toplo-Widget-Select-Filter-TextField' } { #category : #evaluation }