[vwnc] Input Field Font / Setting Text Font

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Input Field Font / Setting Text Font

david.long
Hi everyone,

does anyone know the message you send to an InputField to change its font? I was using TexAttributes #setDefaultTo: but it doesn't seem to get everything.
I have a few canvases that probably need it set directly.

thanks,

David

Your business, your way.
http://sageteagroup.com

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Input Field Font / Setting Text Font

Steven Kelly

At least if you’re on Windows, the font used in InputFields and for labels is the default system widget font, set in WinXPLookPolicy class>>defaultSystemFontDescription. If you want to change the font used in ALL InputFields, I guess you change that method and send initialize to the class. If you want to change the font used in ONE or SOME InputFields, select the InputField in the canvas tool and on the Details page of the GUI Painter Tool, choose the Font you want. You can create new FontDescriptions from Edit | Named Fonts | Define Named Fonts (press Add New Named Font, click a font and size etc. on the right, then click Assign to Named Font). You’ll need to choose a different page then go back to the Details page to see the new Font in the list. You can File Out the definition of the new font(s) to a Smalltalk code file, or Install them in your application.

 

If you want to set the font programmatically when opening (e.g. for a text widget in postBuildWith:):

 

w := aBuilder componentAt: #myTextBox.

w spec style: self style.

w widget textStyle: (TextAttributes styleNamed: self styleSymbol ifAbsent: [])

 

If you want to do it on the fly after the window has opened (again, this code is for a text widget):

 

ComposedTextView>>changeTextStyle: textAttributes

                self textStyle: textAttributes.

                self displayContents wordWrap ifTrue: "keeps text wrapped"

                                [self displayContents setCompositionWidth: self wrappingBox width.

                                self displayContents composeAll].

                self

                                setScrollWidth;

                                changePositionBy: 0@0; "updates vertical scrollbar thumb, scrolls so top of box is top of line"

                                resetSelections;

                                positionToSelection;

                                invalidate.

 

As this is clearly ugly – most of it is hacky code to make sure the display gets updated properly after changing the font - I’d be delighted to hear if anyone has a better solution!

 

HTH,

Steve

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of david
Sent: 03 October 2008 18:07
To: [hidden email]
Subject: [vwnc] Input Field Font / Setting Text Font

 

Hi everyone,

does anyone know the message you send to an InputField to change its font? I was using TexAttributes #setDefaultTo: but it doesn't seem to get everything.
I have a few canvases that probably need it set directly.

thanks,

David

Your business, your way.
http://sageteagroup.com

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc