From 643cdb8bc4f1432eb38645d31a4a0f82888b3819 Mon Sep 17 00:00:00 2001 From: Alain Plantec Date: Sat, 26 Oct 2024 15:11:26 +0200 Subject: [PATCH] small fixe with big effect on example_ThemeSelect: never user #inform: with SDL !!! --- src/Toplo-Examples/ToSandBox.class.st | 9 ++++++--- .../ToSievedListElementEventHandler.class.st | 5 +---- .../ToMultiSelectListElement.class.st | 2 +- .../ToSelectPopupWindowManager.class.st | 7 +++++++ .../ToSingleSelectChangedEvent.class.st | 16 ++++++++-------- .../ToSingleSelectInnerContainerElement.class.st | 6 +++--- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/Toplo-Examples/ToSandBox.class.st b/src/Toplo-Examples/ToSandBox.class.st index 6c32cf4e..f69fa923 100644 --- a/src/Toplo-Examples/ToSandBox.class.st +++ b/src/Toplo-Examples/ToSandBox.class.st @@ -2603,7 +2603,7 @@ ToSandBox class >> example_ThemeSelect [ ('Select a Toplo theme' asRopedText foreground: Color lightGray). select addEventHandlerOn: ToSingleSelectChangedEvent - do: [ :event | self inform: event selectedData asString ]. + do: [ :event | event selectedData asString traceCr ]. select selecter selectIndex: 4. select allowDeselection: false. select openInSpace @@ -3887,12 +3887,15 @@ ToSandBox class >> example_selectWithEditingMultiSelectionWithAllClassNames [ fontSize: 24; foreground: Color lightGray; yourself)) ]. - + select sieve dataFilter: [ :aClass :aPattern | + aClass name + includesSubstring: aPattern asString + caseSensitive: false ]. innerWindow := ToInnerWindow new. select popupWindowManager anchorRoot: innerWindow root. select hMatchParent. select popupListElement dataAccessor updateAllWith: - (Smalltalk globals allClasses collect: [ :cls | cls name ]). + Smalltalk globals allClasses. innerWindow pane addChild: select. innerWindow height: 800. diff --git a/src/Toplo-Widget-List/ToSievedListElementEventHandler.class.st b/src/Toplo-Widget-List/ToSievedListElementEventHandler.class.st index 49b89582..88c3667b 100644 --- a/src/Toplo-Widget-List/ToSievedListElementEventHandler.class.st +++ b/src/Toplo-Widget-List/ToSievedListElementEventHandler.class.st @@ -63,7 +63,7 @@ ToSievedListElementEventHandler >> listSelectionCommandAppliedEvent: aPreNotific " the list selection change event is about to be dispatched. I take care of the sieve internal selectionSet according to the list element selection model" - | listElement listSelModel touchedIndexes | + | listElement listSelModel | listElement := aPreNotification currentTarget. listSelModel := listElement selectionModel. " first check if the request is for the primary selection model " @@ -80,15 +80,12 @@ ToSievedListElementEventHandler >> listSelectionCommandAppliedEvent: aPreNotific - if not empty, the selection set is computed according to the current list node list " sieve pattern ifEmpty: [ - touchedIndexes := aPreNotification command indexes. sieveSelectionModel copySelectionFrom: listSelModel ] ifNotEmpty: [ - touchedIndexes := OrderedCollection new. aPreNotification command indexes do: [ :localIndex | | originalIndex dataItem | dataItem := listElement dataAccessor at: localIndex. originalIndex := dataPositionIndex at: dataItem. - touchedIndexes add: originalIndex. listSelModel transferSelectionFromIndex: localIndex toIndex: originalIndex diff --git a/src/Toplo-Widget-Select/ToMultiSelectListElement.class.st b/src/Toplo-Widget-Select/ToMultiSelectListElement.class.st index 31d01e50..e36e5a4d 100644 --- a/src/Toplo-Widget-Select/ToMultiSelectListElement.class.st +++ b/src/Toplo-Widget-Select/ToMultiSelectListElement.class.st @@ -6,7 +6,7 @@ Class { { #category : #'private - commands' } ToMultiSelectListElement >> applyDataSourceSieveCommand: aDataSourceCommand [ - " update the selection according to the sieve selection model" + " update the selection and the select list according to the sieve selection model" super applyDataSourceSieveCommand: aDataSourceCommand. selectElement checkHideSelectionFromListElement. diff --git a/src/Toplo-Widget-Select/ToSelectPopupWindowManager.class.st b/src/Toplo-Widget-Select/ToSelectPopupWindowManager.class.st index 8d4b51de..4e4e2800 100644 --- a/src/Toplo-Widget-Select/ToSelectPopupWindowManager.class.st +++ b/src/Toplo-Widget-Select/ToSelectPopupWindowManager.class.st @@ -87,6 +87,13 @@ ToSelectPopupWindowManager >> minHeight: aNumber [ listElement minHeight: aNumber ] +{ #category : #'mouse handlers' } +ToSelectPopupWindowManager >> mouseDownInElementEvent: anEvent [ + + super mouseDownInElementEvent: anEvent. + element filterTextField requestFocus +] + { #category : #initialization } ToSelectPopupWindowManager >> newListElement [ diff --git a/src/Toplo-Widget-Select/ToSingleSelectChangedEvent.class.st b/src/Toplo-Widget-Select/ToSingleSelectChangedEvent.class.st index 8117e314..a2e4ade0 100644 --- a/src/Toplo-Widget-Select/ToSingleSelectChangedEvent.class.st +++ b/src/Toplo-Widget-Select/ToSingleSelectChangedEvent.class.st @@ -2,8 +2,8 @@ Class { #name : #ToSingleSelectChangedEvent, #superclass : #BlEvent, #instVars : [ - 'selectedData', - 'selectedIndex' + 'selectedDataArray', + 'selectedIndexes' ], #category : #'Toplo-Widget-Select-Single' } @@ -11,23 +11,23 @@ Class { { #category : #accessing } ToSingleSelectChangedEvent >> selectedData [ - ^ selectedData + ^ selectedDataArray ifNotEmpty: [ :s | s anyOne ] ifEmpty: [ ] ] { #category : #accessing } -ToSingleSelectChangedEvent >> selectedData: aData [ +ToSingleSelectChangedEvent >> selectedDataArray: aDataArray [ - selectedData := aData + selectedDataArray := aDataArray ] { #category : #accessing } ToSingleSelectChangedEvent >> selectedIndex [ - ^ selectedIndex + ^ selectedIndexes ifNotEmpty: [ :s | s anyOne ] ifEmpty: [ 0 ] ] { #category : #accessing } -ToSingleSelectChangedEvent >> selectedIndex: anInteger [ +ToSingleSelectChangedEvent >> selectedIndexes: anArray [ - selectedIndex := anInteger + selectedIndexes := anArray ] diff --git a/src/Toplo-Widget-Select/ToSingleSelectInnerContainerElement.class.st b/src/Toplo-Widget-Select/ToSingleSelectInnerContainerElement.class.st index 32f0038a..25d6e4db 100644 --- a/src/Toplo-Widget-Select/ToSingleSelectInnerContainerElement.class.st +++ b/src/Toplo-Widget-Select/ToSingleSelectInnerContainerElement.class.st @@ -148,14 +148,14 @@ ToSingleSelectInnerContainerElement >> refreshFromPopupListSelection [ dataView removeChildren. selectedIndex isZero - ifTrue: [ ] ifFalse: [ dataItem := originalData at: selectedIndex. dataViewBuilder cull: dataView cull: dataItem ]. changedEvent := ToSingleSelectChangedEvent new. - changedEvent selectedData: dataItem. - changedEvent selectedIndex: selectedIndex. + changedEvent selectedDataArray: + (dataItem ifNil: [ #( ) ] ifNotNil: [ { dataItem } ]). + changedEvent selectedIndexes: { selectedIndex }. selectElement dispatchEvent: changedEvent ]