Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#8129 closed bug (invalid)

BTextControl , SetFontSize() doesnt work?

Reported by: cipri Owned by: axeld
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/alpha3
Keywords: BTextControl Cc:
Blocked By: Blocking:
Platform: All

Description

I tried mytextcontrol->SetFontSize(..) and also mytexcontrol->TextView()->SetFontSize(..) and none worked (as far as i remember). But mytextcontrol->TextView()->SetFontAndColor(..) works like expected.

I'm not sure if that is a bug, or intention, but i think often it would be more conventient if SetFontSize would work too.

Change History (7)

comment:1 by cipri, 13 years ago

It seems

mytextcontrol->TextView()->SetFontAndColor(..)

also doesnt work fully. It sets the font size right, but it doesnt set the color. It keeps displaying the black color.

comment:2 by ttcoder, 13 years ago

I'm probably off on this, but maybe this part of the bebook...

By default, a BTextView displays all its text in a single font and color. The SetStylable() turns on support for multiple character formats

means that the defaults color/size are not only unified but also locked in, and can only be changed after calling mytextontrol->TextView()->SetStylable( true ).. (?)

Not sure why SetFontAndColor() half-works when other setter methods don't work at all though...

Version 0, edited 13 years ago by ttcoder (next)

comment:3 by jackburton, 13 years ago

Resolution: invalid
Status: newclosed

Invalid: as you half guessed, to change font and/or color in a BTextView, you can only use SetFontAndColor(), and not SetFont() or SetFontSize().

comment:4 by cipri, 13 years ago

It's a little unconvenient to define a new font, to define a color, when you in fact needs just the size of the font to be bigger.

And the other problem remains, SetFontAndColor() doesnt set the color you choose, it remains black.

in reply to:  3 comment:5 by jackburton, 13 years ago

Replying to jackburton:

Invalid: as you half guessed, to change font and/or color in a BTextView, you can only use SetFontAndColor(), and not SetFont() or SetFontSize().

Forgot this: If you only need to change the font size, you have to do something like this: (given that "textView" holds a pointer to your BTextView)

BFont font;
textView->GetFontAndColor(0, &font, NULL);
font.SetSize(18);
textView->SetFontAndColor(&font, B_FONT_SIZE, NULL);

This is also true for any other property of the font. Hope this helps.

in reply to:  4 comment:6 by jackburton, 13 years ago

Replying to cipri:

It's a little unconvenient to define a new font, to define a color, when you in fact needs just the size of the font to be bigger.

And the other problem remains, SetFontAndColor() doesnt set the color you choose, it remains black.

IIRC our BTextView implementation checks for NULL values for either font and color, so you can safely pass NULL where you don't want to change anything. Which version of the call you used ? The BTextView was stylable or not ?

comment:7 by cipri, 13 years ago

you see, you need at least 4 lines of code, for just setting a font size.

Yes, I tried also using the "SetStylable(true)" , but the color of the text seems to keep being the same. To be even more sure, I even put that code of changing the font in "AttachedToWindow" after i saw that in the constructor it didnt make a change.

Note: See TracTickets for help on using tickets.