File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -247,10 +247,18 @@ - (NSTouchBarItem*)makeLabelForID:(NSString*)id
247247
248248- (void )updateLabel : (NSCustomTouchBarItem *)item
249249 withSettings : (const mate::PersistentDictionary&)settings {
250+ NSTextField * text_field = (NSTextField *)item.view ;
251+
250252 std::string label;
251253 settings.Get (" label" , &label);
252- NSTextField * text_field = (NSTextField *)item.view ;
253254 text_field.stringValue = base::SysUTF8ToNSString (label);
255+
256+ std::string textColor;
257+ if (settings.Get (" textColor" , &textColor) && !textColor.empty ()) {
258+ text_field.textColor = [self colorFromHexColorString: textColor];
259+ } else {
260+ text_field.textColor = nil ;
261+ }
254262}
255263
256264- (NSTouchBarItem *)makeColorPickerForID : (NSString *)id
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Process: [Main](../tutorial/quick-start.md#main-process)
88
99* ` options ` Object
1010 * ` label ` String (optional) - Text to display.
11+ * ` textColor ` String (optional) - Hex color of text, i.e ` #ABCDEF ` .
1112
1213### Instance Properties
1314
@@ -17,3 +18,8 @@ The following properties are available on instances of `TouchBarLabel`:
1718
1819The label's current text. Changing this value immediately updates the label in
1920the touch bar.
21+
22+ #### ` touchBarLabel.textColor `
23+
24+ The label's current text color. Changing this value immediately updates the
25+ label in the touch bar.
Original file line number Diff line number Diff line change @@ -80,12 +80,15 @@ const finishSpin = () => {
8080 if (uniqueValues === 1 ) {
8181 // All 3 values are the same
8282 result .label = ' 💰 Jackpot!'
83+ result .textColor = ' #FDFF00'
8384 } else if (uniqueValues === 2 ) {
8485 // 2 values are the same
8586 result .label = ' 😍 Winner!'
87+ result .textColor = ' #FDFF00'
8688 } else {
8789 // No values are the same
8890 result .label = ' 🙁 Spin Again'
91+ result .textColor = null
8992 }
9093 spinning = false
9194}
@@ -94,7 +97,9 @@ const touchBar = new TouchBar([
9497 spin,
9598 new TouchBarSpacer ({size: ' large' }),
9699 reel1,
100+ new TouchBarSpacer ({size: ' small' }),
97101 reel2,
102+ new TouchBarSpacer ({size: ' small' }),
98103 reel3,
99104 new TouchBarSpacer ({size: ' large' }),
100105 result
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ TouchBar.TouchBarLabel = class TouchBarLabel extends TouchBarItem {
164164 if ( config == null ) config = { }
165165 this . type = 'label'
166166 this . _addLiveProperty ( 'label' , config . label )
167+ this . _addLiveProperty ( 'textColor' , config . textColor )
167168 }
168169}
169170
You can’t perform that action at this time.
0 commit comments