Skip to content

Commit

Permalink
Remove almost all methods from BlTextAnnouncer (except #postCopy) (as…
Browse files Browse the repository at this point in the history
… a fix for #670)

Introduce BlElement>>focusHolder to allow an element to specify the element that should be focused when a focus is requested.
  • Loading branch information
plantec committed Dec 12, 2024
1 parent 5957d2d commit d17cd27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 58 deletions.
57 changes: 0 additions & 57 deletions src/Bloc-Text/BlTextAnnouncer.class.st
Original file line number Diff line number Diff line change
@@ -1,68 +1,11 @@
Class {
#name : #BlTextAnnouncer,
#superclass : #Announcer,
#instVars : [
'suspendAll',
'suspendedAnnouncemets'
],
#category : #'Bloc-Text-Text'
}

{ #category : #announce }
BlTextAnnouncer >> announce: anAnnouncement [
(self isAnnouncementSuspended: anAnnouncement) ifTrue: [ ^ anAnnouncement asAnnouncement ].
^ super announce: anAnnouncement
]

{ #category : #accessing }
BlTextAnnouncer >> announcer [
^ self
]

{ #category : #testing }
BlTextAnnouncer >> isAnnouncementSuspended: anAnnouncement [
^ self suspendAll or: [ |announcementType|
announcementType := anAnnouncement isClass
ifTrue: [ anAnnouncement ] ifFalse: [ anAnnouncement class ].
self suspendedAnnouncemets anySatisfy: [ :anAnnouncementType |
"Suspend the announcement if it has the same class or if it inherits from a suspended announcement class."
announcementType = anAnnouncementType or: [ announcementType inheritsFrom: anAnnouncementType ] ] ]
]

{ #category : #copying }
BlTextAnnouncer >> postCopy [
super postCopy.
registry := registry copy.
]

{ #category : #accessing }
BlTextAnnouncer >> resetAnnouncer [
registry reset
]

{ #category : #suspending }
BlTextAnnouncer >> suspendAll [
^ suspendAll ifNil: [ suspendAll := false ].
]

{ #category : #suspending }
BlTextAnnouncer >> suspendAll: aCollection while: aBlock [
| previousSuspendedAnnouncemets |
previousSuspendedAnnouncemets := suspendedAnnouncemets.
suspendedAnnouncemets := aCollection copy.
aBlock ensure: [suspendedAnnouncemets := previousSuspendedAnnouncemets]
]

{ #category : #suspending }
BlTextAnnouncer >> suspendAllWhile: aBlock [
| previousSuspensionState |
previousSuspensionState := suspendAll.
suspendAll := true.
aBlock ensure: [suspendAll := previousSuspensionState]

]

{ #category : #accessing }
BlTextAnnouncer >> suspendedAnnouncemets [
^ suspendedAnnouncemets ifNil: [ suspendedAnnouncemets := OrderedCollection new ].
]
9 changes: 8 additions & 1 deletion src/Bloc/BlElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,13 @@ BlElement >> firstCommonParent: anElement ifFound: aFoundBlock ifNone: aNoneBloc
^ aNoneBlock value
]

{ #category : #'focus requesting' }
BlElement >> focusHolder [
"the element that will be actually focused when #requestFocus is sent "

^ self
]

{ #category : #accessing }
BlElement >> focusability [
<return: #BlFocusability>
Expand Down Expand Up @@ -3467,7 +3474,7 @@ BlElement >> requestFocus [
If I am not added to the scene graph mark me as focused in order to re-try focus
request as soon I am added to the scene graph"

self requestFocusDueTo: BlFocusUnknownReason uniqueInstance
self focusHolder requestFocusDueTo: BlFocusUnknownReason uniqueInstance
]

{ #category : #'focus requesting' }
Expand Down

0 comments on commit d17cd27

Please sign in to comment.