Skip to content

Commit 0829e18

Browse files
committed
adding a little FAQ
1 parent ad12808 commit 0829e18

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
75 KB
Loading

Chapters/toplo/skinInAction.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## Skins in Action
2+
3+
### Why my label changes when in space
4+
5+
When we assign a foreground color to a `ToLabel`, this color will be applied when inspecting the label but not when displaying the label in a space.
6+
7+
```
8+
label := ToLabel new text: 'Hello'; foreground: Color blue; yourself.
9+
10+
label inspect.
11+
12+
label openInSpace.
13+
14+
label inspect.
15+
```
16+
17+
![Difference between inspection and space rendering.](figures/helloBlackBlue)
18+
19+
20+
### Skins in Action
21+
22+
What you observe is the label skin in action.
23+
The skin is installed when the label is added in a space.
24+
And the installed default label color is black (for the raw theme).
25+
26+
Now, you have three solutions to customize your label look.
27+
28+
- 1 First you can use a `ToAttributedLabel`, which is a subclass of `ToLabel` without any skin.
29+
- 2 You can send `withNullSkin` directly to the label if you prefer to use a `ToLabel`.
30+
- 3 The default text color is looked-up in the theme. It is stored in the token value named `#’color-text’`. You can redefine it locally with `#addTokenNamed:withValue:`.
31+
32+
We use more and more solution 3 when we want to customize a label in a skin (as an example, in the tab node skin)
33+
34+
### Solution 1
35+
36+
```
37+
| label |
38+
label := ToAttributedLabel new text: 'Hello'; foreground: Color red; yourself.
39+
label openInSpace
40+
```
41+
42+
### Solution 2
43+
44+
```
45+
| label |
46+
label := ToLabel new withNullSkin; text: 'Hello'; foreground: Color red; yourself.
47+
label openInSpace
48+
```
49+
50+
### Solution 3 variation one
51+
52+
```
53+
| label |
54+
label := ToLabel text: 'Hello'.
55+
label addTokenNamed: #'color-text' withValue: Color red.
56+
label openInSpace
57+
```
58+
59+
### Solution 3 variation two
60+
61+
```
62+
| container label |
63+
label := ToLabel text: 'Hello'.
64+
container := ToPane horizontal.
65+
container addChild: label.
66+
container addTokenNamed: #'color-text' withValue: Color red.
67+
container openInSpace
68+
```

index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<!inputFile|path=Chapters/toplo/widgetList.md!>
2525

2626
<!inputFile|path=Chapters/toplo/skinningAWidget.md!>
27+
<!inputFile|path=Chapters/toplo/skinInAction.md!>
2728
<!inputFile|path=Chapters/toplo/definingATheme.md!>
2829
<!inputFile|path=Chapters/toplo/stylesheet.md!>
2930

0 commit comments

Comments
 (0)