AnimalTesting
AnimalTesting

Reputation: 127

How do I change the font of a text field in Pharo?

In Pharo, I am having trouble changing the font of a specific field. I am using UITheme for my openModal file. Below is a reference to my code:

openModal
|builder dialog content login|

builder := UITheme builder.
content := (builder newLabelGroup: {
        'Login' -> (login := (builder
                                        newTextEntryFor: contact 
                                        getText: #login
                                        setText: #login:
                                        help: 'Enter the login of the user')
                                    acceptOnCR: false;
                                    minWidth: 200).
        'Full name' -> ((builder
                        newTextEntryFor: contact 
                        getText: #fullName 
                        setText: #fullName: 
                        help: 'Enter the full name of the user.')
                    acceptOnCR: false;
                    minWidth: 200).
        'Password' -> ((builder
                        newTextEntryFor: contact 
                        getText: #password 
                        setText: #password: 
                        help: 'Enter the password of the user.')
                    acceptOnCR: false;
                    minWidth: 200)
}).

dialog := builder newPluggableDialogWindow:'Edit contact' for: content.
dialog rememberKeyboardFocus: login.
builder openModal: dialog.

I have looked up packages like TextMorph found here: http://files.pharo.org/doc/2.0/class/TextMorph.html#/method/font%253A, but I cannot find a way to implement it to modify the font of one field of the dialog, specifically the password (changing it into a password font). How would I go about doing so?

A solution using an existing package is also welcomed.

Upvotes: 2

Views: 214

Answers (1)

Nicolai Hess
Nicolai Hess

Reputation: 376

you can set the font on the returned widget from the builder, similar to the calls acceptOnCr or minWidth. For example:

    login := (builder
    newTextEntryFor: 'contact'
    getText: #login
    setText: #login:
    help: 'Enter the login of the user')
    font: StandardFonts codeFont;
    acceptOnCR: false;
    minWidth: 200;
    font: StandardFont codeFont

or for the password entry field, just call

beEncrypted

Upvotes: 2

Related Questions