[squeak-dev] Abusing #userInterfaceTheme
marcel.taeumel at hpi.de
Tue Sep 19 11:52:49 UTC 2017
Well, not good. :) Then you would rely on a quite hidden side effect. You do not know in advance how the object stored in a theme will be used by the client. It is not always a simple instVar write.
Consider this example:
slider borderColor: ((self userInterfaceTheme borderColorModifier
ifNil: [ [:c | c adjustBrightness: -0.3] ]) value: aColor).
Am 19.09.2017 12:19:17 schrieb Stéphane Rollandin <lecteur at zogotounga.net>:
> Well, on the one hand, we do want to avoid the need for parentheses:
> self color: (self themed: #color)
Hmm... if we are sure that all setters are always named from the
getters, then this may do the trick:
Object>>getThemed: aSelector ifNone: defaultValue
self perform: (aSelector, ':') asSymbol
with: ((self themed: aSelector) ifNil: [defaultValue])
self color: (self userInterfaceTheme color ifNil: [Color yellow])
self getThemed: #color ifNone: Color yellow
The only hurdle I see is the #asSymbol send which may slow things down a
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev