Subscribe Bookmark RSS Feed

is it possible to keep text left and top position?

Highlighted
ram

Contributor

Joined:

Jun 5, 2017

 Hi ALL,
is there a way to keep text at location provided by x and y. meaning left and top justified?
below is the code. i looked in scripting index, mey be there is something but i could not found.
thanks
ram

a="this is a \!nnewline";
Names Default To Here( 1 );
New Window( "Example",
Graph Box(
Text Color( "red" );
Text( Erased, {50, 20}, a );
)
);
7 REPLIES
SG

Occasional Contributor

Joined:

May 24, 2017

I think you just want to change your coordinates. So, change {50, 20} to the {x, y} position you want. The x will be the position of the left side of text and the y will be the bottom of the text. The update code below will put the text all the way up in the upper left corner, touching the borders of the graph box.

 

a="this is a \!nnewline";
Names Default To Here( 1 );
New Window( "Example",
	Graph Box(
		Text Color( "red" );
		Text( Erased, {0, 90}, a );
	)
);
ram

Contributor

Joined:

Jun 5, 2017

whatever co-ordinate you specify,text aligned in the middle of the y cordinate. i am looking for test aligned to the top of the specified cordinate.
SG

Occasional Contributor

Joined:

May 24, 2017

Interesting. When I run the code with coordinates set to {0, 90} this is my output: 

coordinates {0, 90}coordinates {0, 90}

It only shows in the middle if I set my coordinates to {0, 45}:

coordinates {0, 45}coordinates {0, 45}

ram

Contributor

Joined:

Jun 5, 2017

a="this is a \!nnewline \!nnewline \!nnewline";
Names Default To Here( 1 );
New Window( "Example",
	Graph Box(
		Text Color( "red" );
		Text( Erased, {0, 50}, a );
	)
);

e.g in this pic and JSL. i set y cordinate 50 but my text is centered to 50. but what i want it to start from 50 and go down. Any solution

SG

Occasional Contributor

Joined:

May 24, 2017

Oh, I see. Sorry, I misunderstood. You need to use the {left, top, right, bottom} coordinates. It shows under Example 2 in the Scripting Index for Text. Essentially what it does is create a box with lines at the specified coordinates which your text will be placed in. If you make the "right" coordinate too small it will cut off the text. As you make it larger, the box expands, which will start to move the text over as well. I'm not sure if there is an easy way to just specify top and left numbers without the others.

 

a="this is a \!nnewline \!nnewline \!nnewline";
Names Default To Here( 1 );
New Window( "Example",
	Graph Box(
		Text Color( "red" );
		Text( Erased, {0, 50, 15, 20}, a );
	)
);

new.PNG

 

ram

Contributor

Joined:

Jun 5, 2017

ya ...another bad example. in this way you are fixing the number of new line. if i have more new line it will not show up in the defined co-rdinates. e.g you can try 5-6 new line with the same xy cordinate.

 

SG

Occasional Contributor

Joined:

May 24, 2017

You can lower the value for the bottom of the box, but of course if you end up with more text than will fit in the box it will again be cut off. Again, I'm not sure of a way to only have the text line up to just a top and left coordinate.

 

a="this is a \!nnewline \!nnewline \!nnewline \!nnewline \!nnewline \!nnewline";
Names Default To Here( 1 );
New Window( "Example",
	Graph Box(
		Text Color( "red" );
		Text( Erased, {0, 50, 15, 0}, a );
	)
);