Normal Topic Centering text in a text element. (Read 757 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Centering text in a text element.
Sep 20th, 2007 at 7:41pm
Print Post Print Post  
This may be a silly basic question, however in all the time I have used Sesame I have never had the need to center text and I can not seem to find much about it by searching the forum or Inside Sesame. Sometimes I have trouble seeing the forest through the trees, So I figured I would ask.

I have a form that has a large Image Box in the center. I have a Text box above it that has specific information about the Item in the image box being displayed. What is the best method to center the text so it looks proper above the Image box?

Do I figure out the number of characters my text box will display then count the characters of my text, figure out the center point and then pad front with blanks?

I tried using the attribute commands to set the label of the image box to my text and have that set to position 11 (top center) but as you guys and gals probably know that will not work.

Am I overlooking an easy to use command or technique?

What I am doing for now is using a command button with no Sbasic to do anything, so it just sits there. and I have on form entry code of:


      Attribute(Header, ATTR_ID_LABEL, CatDesc)
     ForceRedraw()


Thanks







  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Centering text in a text element.
Reply #1 - Sep 20th, 2007 at 8:39pm
Print Post Print Post  
I suppose you could set the postion with a formula.

Find Center point of Canvas. Eg =500
Make the width of the element to be centered as tight as possible, no extra space on the ends.
Get width of element to be centered  Eg = 60
Set X pos of element  = ( CanvasCenter - 1/2 of element width) = (500 - 60/2) = 470

If all forms are same canvas size, then use a global variable for CanvasCenter value?

This only works to center the single element of text on a line with no other elements., should center on the form
=============================================
Could take a similar approach to center within each element:

Get width element image. Eg = 100
Get length of element value.  Eg = 40
Add half the remaining space to front of element value = (100 - 40)/2 = 30 = ElementValue = @text(30," ") + ElementValue.
But would have to make sure to remove leading spaces if you change the ElementValue or this would keep adding front spaces.  Would also need to drop leading spaces if used in any other strings, merges, etc.

(Yeh, I know, use variables)
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Centering text in a text element.
Reply #2 - Sep 20th, 2007 at 9:04pm
Print Post Print Post  
Does the user need to edit the text?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Centering text in a text element.
Reply #3 - Sep 20th, 2007 at 9:17pm
Print Post Print Post  
Hammer wrote on Sep 20th, 2007 at 9:04pm:
Does the user need to edit the text?


No. The user never edits the text. If there is no quick answer, its not a big deal. I do not want anyone to waste any time on this. Using a command button as a place holder and changing its label attribute works Great, I just thought I was overlooking the correct technique.

I will just consider my command button text holder as a new self centering text widget.  Smiley

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Centering text in a text element.
Reply #4 - Sep 20th, 2007 at 9:22pm
Print Post Print Post  
You're pretty close, but I'd use a static text instead of a command button.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Centering text in a text element.
Reply #5 - Sep 20th, 2007 at 9:58pm
Print Post Print Post  
Thanks Erika.

The reason I used a command button element instead of  static text element is it automatically centers the text nicely without me having to set the look feature to 11.

Is there a bad drawback to using a command button?

Thanks again for the help, (and a belated happy new years)
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Centering text in a text element.
Reply #6 - Sep 21st, 2007 at 10:32am
Print Post Print Post  
BOBSCOTT wrote on Sep 20th, 2007 at 9:58pm:
Is there a bad drawback to using a command button?

Not really. As long as people aren't confused by a button that doesn't do anything.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged