Loading...
Logo
Processing Forum
Does anyone know how to style the vertical alignment of text on a G4P button? It seems the alignment constants are for horizontal alignment only.

I would like the text to be centered horizontally and vertically on the button, but it seems to be drifting towards the top.

Replies(6)

G4P will always (attempt to) centre text vertically based on the button and font size. At present it is not possible for the user to specify a different vertical alignment.

If you want this feature please post it as an issue here and I will look at it for the next version.

Thanks quarks.

another question for you:

when using P3D mode, the text on the buttons is blurry. Do you know of any workaround for this issue? I am calling textMode(SCREEN) in the setup() function, which fixes the text in the rest of the app, but not the button text.

unfortunately, using OPENGL mode is turing out to not be an option for this project 
so any help you can give would be most appreciated.

thanks again for the library!

Text is can be bad with P3D and G4P uses the standard Processing text method.
A couple of options are open to you
  • you might try a larger font size and experiment with different fonts
  • or you might create bitmaps for the button faces and use the GImageButton component introduced in the latest version of G4P
II will have to investigate textMode(SCREEN) and see if this might be added as new feature for G4P mmmm...
Both these problems are now fixed with latest version G4P (V1.6.2)

Buttons and labels now support both horizontal and vertical alignment see example

Add the following line after the call to size() in setup()
Copy code
  1. G4P.setTextMode(SCREEN);

Hi quarks,

Thanks for your changes...I'm actually considering using image buttons now 

Regarding your reply from 6/24 about  GImageButton,

It seems the link to the pde at the bottom of the page is broken.

It would be great to see an example of how to use it in the code. I am imagining I need to create an off/over/click image for each button and then the code would swap between them?

Thanks again for your help.





Sorry for the delay in getting back to you and sorry for the broken link - I will fix it when I get a chance.

You can still see the code as it is an example included with the library download.

Select
File | SketchBook | libraries | guicomponents | examples G4P_ImageButtons
from the menu bar in Processing.