Add mode prop to segmented touch bar control

This commit is contained in:
Samuel Attard 2017-04-28 14:50:58 +10:00
parent 79b02ca71e
commit 225ccab3d2
No known key found for this signature in database
GPG key ID: E89DDE5742D58C4E
2 changed files with 11 additions and 1 deletions

View file

@ -520,6 +520,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
else
control.segmentStyle = NSSegmentStyleAutomatic;
std::string segmentMode;
settings.Get("mode", &segmentMode);
if (segmentMode == "multiple")
control.trackingMode = NSSegmentSwitchTrackingSelectAny;
else if (segmentMode == "buttons")
control.trackingMode = NSSegmentSwitchTrackingMomentary;
else
control.trackingMode = NSSegmentSwitchTrackingSelectOne;
std::vector<mate::Dictionary> segments;
settings.Get("segments", &segments);

View file

@ -264,11 +264,12 @@ TouchBar.TouchBarSegmentedControl = class TouchBarSegmentedControl extends Touch
constructor (config) {
super()
if (config == null) config = {}
const {segmentStyle, segments, selectedIndex, change} = config
const {segmentStyle, segments, selectedIndex, change, mode} = config
this.type = 'segmented_control'
this._addLiveProperty('segmentStyle', segmentStyle)
this._addLiveProperty('segments', segments || [])
this._addLiveProperty('selectedIndex', selectedIndex)
this._addLiveProperty('mode', mode)
if (typeof change === 'function') {
this.onInteraction = (details) => {