[Cuis-dev] Change in HoverHelpMorph

Hilaire Fernandes hilaire at drgeo.eu
Thu Nov 4 05:50:55 PDT 2021


Hi Hernan,

Yes tooltips shoud be formatted by the system to look uniform. Also it 
makes life easier for translators, they does not have to worry about how 
to hand format the paragraphs, being consistent from one translation to 
another one, etc. So you really want the system to deal with it.

This was the behavior I experienced on GTK+, Squeak and Pharo.

Before my change, Cuis presented tool-tips occupying half of the screen 
width. This was really odd. I have very long tool-tips in DrGeo, so it 
was a problem. To deal with hand formatted tool-tips, I set this 
detection of linefeed, so in this case no system formatting takes place.

I did not anticipate your situation, sorry for the inconvenience.

What we could do is to use a property to force for un-formatted tool 
tips. This is what proposes the attached change set. The only 
inconvenience for you is to set the property #balloonUnformatted for 
each morph you want its tool tips un-formatted.

Is it an acceptable solution for you?

Best

Hilaire


Le 04/11/2021 à 02:14, Hernan Wilkinson a écrit :
> Hi Hilaire,
>  the change set number 4922 changes the behavior of the HoverHelpMorph.
>  I use it in LiveTyping to show the types of variables, returns, etc.
>  Before that change set, the types were shown in a line, for example:
>  < Morph # InnerListMorph | HandMorph | WidgetMorph >
>  With the change, the width of the hover help is much smaller and it 
> shows something like this:
>  < Morph # InnerListMorph
> | HandMorph
> | WidgetMorph >
>
>  Why did you make that change? I do not understand why if the contents 
> does not includes a line feed you are limiting the width to 300... the 
> strings I'm using do not have a line feed. The code is bellow.
>
> contents: aString
> | width |
> contents _ aString.
> width _ (contents includes: Character lf)
> ifTrue: [9999999] ifFalse: [300].
> textComposition _ TextComposition new.
> textComposition
> setModel: (TextModel withText: contents asText);
> extentForComposing: width at 9999999.
> textComposition composeAll.
> self morphExtent: textComposition usedExtent + 8
>
> Thanks!
> Hernan.
>
-- 
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/20211104/23994dc6/attachment.htm>
-------------- next part --------------
'From Cuis 5.0 [latest update: #4958] on 4 November 2021 at 1:45:34 pm'!

!HoverHelpMorph methodsFor: 'accessing' stamp: 'hlsf 11/4/2021 13:41:42'!
contents: aString formatted: isFormatted
	| width |
	contents _ aString.
	width _ (isFormatted and: [(contents includes: Character lf) not])
		ifTrue: [300] ifFalse: [9999999].
	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 11/4/2021 13:25:02'!
contents: aString for: aMorph
	"Make up and return a HoverHelp for morph."
	^self new
		contents: aString  
		formatted: (aMorph hasProperty: #balloonUnformatted) not! !


!Morph methodsFor: 'halos and balloon help' stamp: 'hlsf 11/4/2021 13:22:30'!
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 for: self.
	
	"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: stamp: 'hlsf 11/4/2021 13:22:37'!
HoverHelpMorph class removeSelector: #contents:!
!methodRemoval: HoverHelpMorph #contents: stamp: 'hlsf 11/4/2021 13:31:47'!
HoverHelpMorph removeSelector: #contents:!


More information about the Cuis-dev mailing list