<commit_before>"
I can add a popup on an element when a move over event occurs.

Here is an example:
-=-=-=-=
c := RSCanvas new.

classes := RSObject withAllSubclasses.

scale := TSScale linear
	domain: { (classes collect: #numberOfMethods) min . (classes collect: #numberOfMethods) max};
	range: { 'red'. 'blue' }.

classes do: [ :cls |
	| b |
	b := RSEllipse new.
	b size: cls numberOfMethods.
	b color: (scale scale: cls numberOfMethods).
	b model: cls.
	b @ RSPopup.
	c add: b ].

RSFlowLayout on: c shapes.

c @ RSControlsCanvas
-=-=-=-=
"
Class {
	#name : #RSPopup,
	#superclass : #RSInteraction,
	#instVars : [
		'shapeBuilder'
	],
	#classInstVars : [
		'removeEvents'
	],
	#category : #'Roassal3-Interaction-Popup'
}

{ #category : #accessing }
RSPopup class >> activationEvent [
	^ RSMouseMove
]

{ #category : #accessing }
RSPopup class >> removeEvents [
	^ removeEvents ifNil: [ 
		removeEvents := { RSMouseClick. RSMouseEnter. RSMouseLeave. RSMouseDragging } ]
]

{ #category : #'instance creation' }
RSPopup class >> reset [
	<script: 'self reset'>
	super reset.
	removeEvents := nil.
]

{ #category : #accessing }
RSPopup class >> text: anObject [
	| inst |
	inst := self new.
	inst shapeBuilder textBlock: anObject.
	^ inst
]

{ #category : #hooks }
RSPopup >> createOrGetPopupOn: aShape event: event [
	| att popupShape canvas |
	att := event canvas attributes.
	att at: #popup ifPresent: [ :popup | ^ popup ].
	popupShape := shapeBuilder shapeFor: aShape model.
	att at: #popup put: popupShape.
	popupShape isFixed: true.
	canvas := aShape canvas.
	canvas addShape: popupShape.
	^ popupShape
	
]

{ #category : #initialization }
RSPopup >> initialize [
	super initialize.
	shapeBuilder := RSSimplePopupBuilder new.
]

{ #category : #hooks }
RSPopup >> onShape: aShape [
	self registerRemoveEventsOn: aShape.
	aShape
		when: self class activationEvent do: [ :evt | | popup |
			popup := self createOrGetPopupOn: aShape event: evt.
			self translatePopup: popup event: evt.<commit_msg>fix for popup, now you can stacks popups in shapes removing the previous one<commit_after>"
I can add a popup on an element when a move over event occurs.

Here is an example:
-=-=-=-=
c := RSCanvas new.

classes := RSObject withAllSubclasses.

scale := TSScale linear
	domain: { (classes collect: #numberOfMethods) min . (classes collect: #numberOfMethods) max};
	range: { 'red'. 'blue' }.

classes do: [ :cls |
	| b |
	b := RSEllipse new.
	b size: cls numberOfMethods.
	b color: (scale scale: cls numberOfMethods).
	b model: cls.
	b @ RSPopup.
	c add: b ].

RSFlowLayout on: c shapes.

c @ RSControlsCanvas
-=-=-=-=
"
Class {
	#name : #RSPopup,
	#superclass : #RSInteraction,
	#instVars : [
		'shapeBuilder'
	],
	#classInstVars : [
		'removeEvents'
	],
	#category : #'Roassal3-Interaction-Popup'
}

{ #category : #accessing }
RSPopup class >> activationEvent [
	^ RSMouseMove
]

{ #category : #accessing }
RSPopup class >> removeEvents [
	^ removeEvents ifNil: [ 
		removeEvents := { RSMouseClick. RSMouseEnter. RSMouseLeave. RSMouseDragging } ]
]

{ #category : #'instance creation' }
RSPopup class >> reset [
	<script: 'self reset'>
	super reset.
	removeEvents := nil.
]

{ #category : #accessing }
RSPopup class >> text: anObject [
	| inst |
	inst := self new.
	inst shapeBuilder textBlock: anObject.
	^ inst
]

{ #category : #hooks }
RSPopup >> createOrGetPopupOn: aShape event: event [
	| att popupShape canvas |
	att := event canvas attributes.
	att at: #popup ifPresent: [ :popup | ^ popup ].
	popupShape := shapeBuilder shapeFor: aShape model.
	att at: #popup put: popupShape.
	popupShape isFixed: true.
	canvas := aShape canvas.
	canvas addShape: popupShape.
	^ popupShape
	
]

{ #category : #initialization }
RSPopup >> initialize [
	super initialize.
	shapeBuilder := RSSimplePopupBuilder new.
]

{ #category : #hooks }
RSPopup >> onShape: aShape [
	aShape removeInteractionIfPresent: self class.
	
	self registerRemoveEventsOn: aShape.
	aShape
		when: self class activationEvent do: [ :evt | | popup |
			popup := self createOrGetPopupOn: aShape event: evt.
			self translatePopup: popup event: evt.
{'fraction_non_alphanumeric': 0.1261852662290299, 'fraction_numerical': 0.0004862630683199611, 'mean_word_length': 3.874407582938389, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '1874552', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1441, 'n_words': 424}