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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…