Hey guys… I have this question… How do I change the font all over the app ?
I mean… I suppose I don’t have to go in EVERY control and change the font… or do I ?
TIA
Do you need to do this 1) once or 2) do you want to make your app have a preferences for different fonts?
- Yes, do it manually.
- Use the Observer pattern. There should be an example if the Xojo examples folder.
I thought I could do this from the IDE… Just want to change the look of the UI…
I’ll check out the example you mentioned…
You can do this. It’s just a bit of work. You need to make sure that there is enough space, though. For instance, I my own app I have 5 areas where I allow the user to change the font and the font size.
The observer pattern is as follows: you have a subject, for the font that would be where you show the user the font list. The controls then implement an interface called observer. Whenever the font is changed the observer gets notified and is responsible to change the font.
I think I got the idea regarding the observer pattern method… Not 100% sure I would know how to code it…
But still, I don’t want the user to select the font… I just want to change the appearance of the controls in my app. After a lot of time I realized that the font I chose wasn’t the font that better fits my app… But I will definitely NOT go one by one, every single control…
Thanks
[quote=270545:@Roman Varas]I thought I could do this from the IDE… Just want to change the look of the UI…
I’ll check out the example you mentioned…[/quote]
I might misunderstand, but if you want to change all fonts while developing in the IDE, not when running, just search project and replace those you want. Ie: seach for Courier New and replace it with Dingbats for fun.
That did the trick, Peter… I just have to be a bit careful, as the current font is ‘system’ so that keyword appears quite a few times…
thanks!
Roman, didn’t I ask you what you want to do???
I thought I had answered you… Sorry If I wasn’t clear enough.
Another (more manual) way is to select all the controls with a font and then the properties pane font section will modify them all.
You have to select only those controls with a font as the properties pane only show those properties common to all selected. And you’ll have to go through each Window and ContainerControl individually. More steps than search/replace but just something to know.
I use this method in all windows …
kk_font is a constant in main module apps
dim c as control
for i as integer = 0 to self.ControlCount -1
c = self.Control(i)
// this is my custom control
if c IsA TextFieldKoala then
TextFieldKoala©.TextFont = Minicontab.kk_font
end if
if c IsA Label then
Label(c).TextFont = Minicontab.kk_font
end if
if c isA GroupBox then
GroupBox(c).TextFont = Minicontab.kk_font
end if
if c isA CheckBox then
CheckBox(c).TextFont = Minicontab.kk_font
end if
if c isA ComboBox then
ComboBox(c).TextFont = Minicontab.kk_font
end if
if c isA RadioButton then
RadioButton(c).TextFont = Minicontab.kk_font
end if
if c isA Listbox then
Listbox(c).TextFont = Minicontab.kk_font
end if
if c isA PopupMenu then
PopupMenu(c).TextFont = Minicontab.kk_font
end if
if c isA TextArea then
TextArea(c).TextFont = Minicontab.kk_font
end if
if c isA TabPanel then
TabPanel(c).TextFont = Minicontab.kk_font
end if
if c isA PushButton then
PushButton(c).TextFont = Minicontab.kk_font
end if
next