I am trying to add style to SpTextPresenter
(Pharo 9, Spec 2, Windows 10). I have MyApp
class:
SpApplication subclass: #MyApp
instanceVariableNames: ''
classVariableNames: ''
package: 'MyAdm'
with class method uniqueInstance
(and class instance - "singleton" idea was copy-pasted from LibC):
uniqueInstance
^ uniqueInstance ifNil: [ uniqueInstance := self new ]
and an instance method initialize
:
initialize
super initialize.
self useBackend: #Morphic with: MyAppConfiguration new.
and MyAppConfiguration
class:
SpMorphicConfiguration subclass: #MyAppConfiguration
instanceVariableNames: ''
classVariableNames: ''
package: 'MyAdm'
with the method configure
:
configure: anApplication
super configure: anApplication.
self styleSheet addClass: 'text' with: [ :style |
style addPropertyFontWith: [ :font |
font bold: true;
size: 20;
name: 'Courier'
].
].
Somewhere in the code I do:
.....
"presenterClass is an argument which is a class of my presenter"
presenter := MyApp uniqueInstance newPresenter: presenterClass.
presenter openWithSpec.
presenter updatePresenter.
....
I have several presenters, but one of them really contains text
variable which is created in a initializePresenters
method:
initializePresenters
text := self newText addStyle: 'text'.
super initializePresenters
But the result is bad - the text
has standard view, with a standard font, nothing changed! Where is the bug? I want to see in the text
(of SpTextPresenter
type) my custom font.
EDIT: btw, this does not work too.
Yes, if you declare a singleton and you save the image, it will stay alive between sessions. As anything in Pharo, because is a live environment.
Now, that question makes me think you are lacking the basics of Pharo. And as I said here before (in other question), learning by stackoverflow is not the best way to learn Pharo.
Take a look at this site: https://pharo.org/documentation, there are a lot of resources for learning there.
Also, there a discord server where you can ask anything and there will be a lot of people willing to help you (me included) there: https://discord.gg/QewZMZa