[Cuis-dev] Tool tip again

Hilaire Fernandes hilaire at drgeo.eu
Wed Dec 1 08:51:17 PST 2021


Here is a change set which simplify and allow multiple use cases:

- string with LF will be set as is in the balloon

- text without LF will be wrapped

- morph with the property #balloonUnwrapped will have its string balloon 
unwrapped.

The default behavior is to wrap the balloon all over the system, except 
when balloon contains LF. If a morph want its balloon unwrapped, set the 
ad-hoc property #balloonUnwrapped

A method isBalloonWrapped informs about the property

Hope it helps

Hilaire

-- 
GNU Dr. Geo
http://drgeo.eu
http://blog.drgeo.eu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20211201/ad0c9124/attachment.htm>
-------------- next part --------------
'From Cuis 5.0 [latest update: #4992] on 1 December 2021 at 5:45:32 pm'!

!Morph methodsFor: 'testing' stamp: 'hlsf 12/1/2021 17:35:09'!
isBalloonWrapped
	^ (self hasProperty: #balloonUnwrapped) not! !


!HoverHelpMorph methodsFor: 'accessing' stamp: 'hlsf 12/1/2021 17:07:25'!
contents: aString wrapped: wrapped
"If wordWrapWidthOrNil is nil, don't do wordwrap, and make the morph as wide as needed"
"If text contains line feed, it is hand formatted so ignore word wrapping"
	| width |
	contents _ aString.
	width _ ((contents includes: Character lf) or: [wrapped not])
		ifTrue: [9999999] ifFalse: [FontFamily defaultLineSpacing * 20].
	textComposition _ TextComposition new.
	textComposition
		setModel: (TextModel withText: contents asText);
		extentForComposing: 	width at 9999999.
	textComposition composeAll.
	self morphExtent: textComposition usedExtent + 8.! !


!HoverHelpMorph class methodsFor: 'instance creation' stamp: 'hlsf 12/1/2021 17:09:26'!
contents: aString wrapped: isWrapped
	"Make up and return a HoverHelp for morph.
	(HoverHelpMorph contents: 'This is a HoverHelpMorph') openInHand
	"

	^self new contents: aString wrapped: isWrapped! !


!Morph methodsFor: 'halos and balloon help' stamp: 'hlsf 12/1/2021 17:34:34'!
showBalloon: msgString hand: aHand
	"Pop up a balloon containing the given string,
	first removing any existing BalloonMorphs in the world."

	| w balloon h |
	(w _ self world) ifNil: [^ self].
	h _ aHand.
	h ifNil:[
		h _ w activeHand].
	balloon _ HoverHelpMorph 
		contents: msgString 
		wrapped: self isBalloonWrapped.
	
	"Do it in a while. In some cases, processing the event that might have triggered us might also remove any Help Balloon"
	UISupervisor whenUIinSafeState: [
		balloon popUpForHand: h ]! !

!methodRemoval: HoverHelpMorph class #contents:wrappedTo: stamp: 'hlsf 12/1/2021 17:36:30'!
HoverHelpMorph class removeSelector: #contents:wrappedTo:!
!methodRemoval: HoverHelpMorph class #contents: stamp: 'hlsf 12/1/2021 17:36:43'!
HoverHelpMorph class removeSelector: #contents:!
!methodRemoval: HoverHelpMorph class #contentsWrapped: stamp: 'hlsf 12/1/2021 17:36:04'!
HoverHelpMorph class removeSelector: #contentsWrapped:!
!methodRemoval: HoverHelpMorph #contents: stamp: 'hlsf 12/1/2021 17:36:24'!
HoverHelpMorph removeSelector: #contents:!
!methodRemoval: HoverHelpMorph #contents:wrappedTo: stamp: 'hlsf 12/1/2021 17:36:49'!
HoverHelpMorph removeSelector: #contents:wrappedTo:!
!methodRemoval: HoverHelpMorph #contentsUnwrapped: stamp: 'hlsf 12/1/2021 17:36:33'!
HoverHelpMorph removeSelector: #contentsUnwrapped:!
!methodRemoval: HoverHelpMorph #contentsWrapped: stamp: 'hlsf 12/1/2021 16:53:34'!
HoverHelpMorph removeSelector: #contentsWrapped:!


More information about the Cuis-dev mailing list