HyperNext Studio

HyperNext Studio => General => Topic started by: venkat0249 on September 27, 2011, 04:18:38 PM

Title: text alignment functionality in canvas
Post by: venkat0249 on September 27, 2011, 04:18:38 PM
is it possible to align text in canvas? means "align left","align right","centered" like that....Text align command is there for fields,listboxes, text box, but for canvas is there any such command? if not can we avail that functionality (text alignment) by writing a code specially?
Title: Re: text alignment functionality in canvas
Post by: tigabyte on September 28, 2011, 06:54:02 AM
The canvases don't have an alignment command but the CanvasTextWidthFN function returns the width of the specified text. With this function and knowledge of the canvas width you could align your text. I'll let you have fun working it out for centering.

Code: [Select]
@ Right align for canvas 1
Local text,twidth,cwidth,xpos

Put CanvasWidthFN(1) into cwidth

Put 'Hello World' into text
Put CanvasTextWidthFN(1,text) into twidth

@ align right
Put cwidth into xpos
Subtract twidth from xpos
CanvasDrawText(1,text,20,xpos)

I haven't ran this code so there might be some typos.
Title: Re: text alignment functionality in canvas
Post by: venkat0249 on September 28, 2011, 01:05:01 PM
thank u...i got u... ;)