Skip to content

Commit

Permalink
small fixe with big effect on example_ThemeSelect: never user #inform…
Browse files Browse the repository at this point in the history
…: with SDL !!!
  • Loading branch information
plantec committed Oct 26, 2024
1 parent 5e9469e commit 643cdb8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
9 changes: 6 additions & 3 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-Select/ToMultiSelectListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/Toplo-Widget-Select/ToSelectPopupWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down
16 changes: 8 additions & 8 deletions src/Toplo-Widget-Select/ToSingleSelectChangedEvent.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ Class {
#name : #ToSingleSelectChangedEvent,
#superclass : #BlEvent,
#instVars : [
'selectedData',
'selectedIndex'
'selectedDataArray',
'selectedIndexes'
],
#category : #'Toplo-Widget-Select-Single'
}

{ #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
]
Original file line number Diff line number Diff line change
Expand Up @@ -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
]

Expand Down

0 comments on commit 643cdb8

Please sign in to comment.