Notifications
Clear all

[Closed] gw.text – multiple lines?

Hello!

I worte a script that displays infos in the viewport via "gw.text" and a viewportRedrawCallback. It is supposed to display several infos in several lines but since the "gw.text" command doesn't seem to support the line breaking "

” or “\r” in a string I had to write a workaround. It works, but not satisfyingly since the text is not displayed in the proper position when we look in a flat angle onto the constructionPlane.

Is there another way to do linebreaking in gw.text? Or is there another "workaround" to solve this problem?

Thanks in advance,
Martin

Here is the simplified script - at the moment it only displays name and pos of helpers:
try (
 	destroyDialog myShowAppData
 	unRegisterRedrawViewsCallback fnShowAppData
 )
 catch()
 
 global fnShowAppData
 global intShiftVar
 
 fn fnAddViewportText infoIN nodeIN colorIN = ( -- function that creates a line of text in the graficwindow
 			tempPointVar = gw.transpoint (nodeIN.pos + [1,1,10]) -- converting 3d.pos of node into 2d coords
 			tempPointVar.y += intShiftVar -- shifting the text downward to the next line
 			temp3DPosVar = gw.getPointOnCP [tempPointVar.x,tempPointVar.y] -- converting 2d back to 3d coords for the gw.text-command
 			gw.text temp3DPosVar infoIN color:colorIN -- adding the textline
 			intShiftVar += 15 -- changing var for shifting the next textline downward
 )
 
 rollout myShowAppData "RDT - Show AppData" (
 	checkbutton mySSB01 "Show appData"
 	on mySSB01 changed arg do (
 		if arg == true then ( -- if checked, the callback will be registered
 		unRegisterRedrawViewsCallback fnShowAppData -- clear old callback	(this line is redundant)
 
 			fn fnShowAppData = ( -- fn that cycles through all helpers and dislays some infos
 				gw.setTransform (matrix3 1)
 				for x in helpers where not x.isHidden do (
 					intShiftVar = 0
 					clrDisplayInfoColor = green -- textcolor
 					fnAddViewportText x.name x clrDisplayInfoColor -- drawing the first line of text with the first argument as content
 					fnAddViewportText (x.pos as string) x clrDisplayInfoColor -- second line of text is added
 				)	
 				gw.enlargeUpdateRect #whole
 				gw.updateScreen()
 			)
 			RegisterRedrawViewsCallback fnShowAppData
 			format "%
" "Registered showAppData-Callback"
 		) else ( -- if checkbox is unchecked, the callback is unregistered
 			unRegisterRedrawViewsCallback fnShowAppData
 			format "%
" "Unregistered showAppData-Callback"
 		)
 		completeRedraw()
 	)
 	on myShowAppData close do ( -- closing the rollout unregisters the callback, too
 	unRegisterRedrawViewsCallback fnshowAppData
 	fnshowAppData = undefined
 	format "%
" "Unregistered showAppData-Callback"
 )
 ) -- end RO
 
 createDialog myShowAppData
 
1 Reply