<commit_before>"
I fire an ${class:BlElementAddedToSceneGraphEvent}$ on ${method:BlSceneInformingElement>>#onAddedToSceneGraph|label=#selector}$.
I fire an ${class:BlElementRemovedFromSceneGraphEvent}$ on ${method:BlSceneInformingElement>>#onRemovedFromSceneGraph|label=#selector}$.

I can be used if an object (model) needs to be informed when I am attached to a scene and when I am removed from a scene.

You can use ${class:BlElementAddedToSceneGraphEventHandler}$ and ${class:BlElementRemovedFromSceneGraphEventHandler}$ to perform specific actions.

"
Class {
	#name : #BlSceneInformingElement,
	#superclass : #BlElement,
	#category : #'Bloc-Basic'
}

{ #category : #'hooks - children' }
BlSceneInformingElement >> onAddedToSceneGraph [
	| anEventHandler |
	super onAddedToSceneGraph.
	anEventHandler := nil.
	anEventHandler := BlEventHandler on: BlSpaceClosedEvent do: [ :anEvent |
		self fireEvent: BlElementRemovedFromSceneGraphEvent new.
		anEvent space removeEventHandler: anEventHandler ].
	self fireEvent: (BlElementAddedToSceneGraphEvent new element: self).
]

{ #category : #'hooks - children' }
BlSceneInformingElement >> onRemovedFromSceneGraph [
	super onRemovedFromSceneGraph.
	self fireEvent: (BlElementRemovedFromSceneGraphEvent new element: self).
]<commit_msg>add `BlSceneInformingElement` convenience methods [feenkcom/gtoolkit#793]<commit_after>"
I fire an ${class:BlElementAddedToSceneGraphEvent}$ on ${method:BlSceneInformingElement>>#onAddedToSceneGraph|label=#selector}$.
I fire an ${class:BlElementRemovedFromSceneGraphEvent}$ on ${method:BlSceneInformingElement>>#onRemovedFromSceneGraph|label=#selector}$.

I can be used if an object (model) needs to be informed when I am attached to a scene and when I am removed from a scene.

You can use ${class:BlElementAddedToSceneGraphEventHandler}$ and ${class:BlElementRemovedFromSceneGraphEventHandler}$ to perform specific actions.

"
Class {
	#name : #BlSceneInformingElement,
	#superclass : #BlElement,
	#category : #'Bloc-Basic'
}

{ #category : #'api - event handlers' }
BlSceneInformingElement >> onAddedToSceneDo: aBlock [
	self addEventHandler: (BlElementAddedToSceneGraphEventHandler new valuable: aBlock)
]

{ #category : #'hooks - children' }
BlSceneInformingElement >> onAddedToSceneGraph [
	| anEventHandler |
	super onAddedToSceneGraph.
	anEventHandler := nil.
	anEventHandler := BlEventHandler on: BlSpaceClosedEvent do: [ :anEvent |
		self fireEvent: BlElementRemovedFromSceneGraphEvent new.
		anEvent space removeEventHandler: anEventHandler ].
	self fireEvent: (BlElementAddedToSceneGraphEvent new element: self).
]

{ #category : #'api - event handlers' }
BlSceneInformingElement >> onRemovedFromSceneDo: aBlock [
	self addEventHandler: (BlElementRemovedFromSceneGraphEventHandler new valuable: aBlock)
]

{ #category : #'hooks - children' }
BlSceneInformingElement >> onRemovedFromSceneGraph [
	super onRemovedFromSceneGraph.
	self fireEvent: (BlElementRemovedFromSceneGraphEvent new element: self).
]
{'fraction_non_alphanumeric': 0.09479305740987984, 'fraction_numerical': 0.0010013351134846463, 'mean_word_length': 7.1, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6601517', 'n_tokens_mistral': 872, 'n_tokens_neox': 881, 'n_words': 230}