我想TouchBarSlider
根据我将其移动到的位置来显示值。TouchBar
可以在此处遵循的示例示例。我仍然无法弄清楚如何使用他们给定的方法change
从TouchBarSlider
.
我的电流main.js
如下所示。
const {app, BrowserWindow, TouchBar} = require('electron')
const {TouchBarLabel, TouchBarSlider} = TouchBar
const slider = new TouchBarSlider({label: 'angle',
minValue: 0,
maxValue: 360})
const result = new TouchBarLabel()
result.label = '30' + ' deg';
const updateBar = () => {
let timeout = 100;
if (slider.change()){
result.label = slider.values.toString() + ' deg'
}
setTimeout(updateBar, timeout)
}
const touchBar = new TouchBar([
slider, // add slider
result // add display for slider value but doesn't work yet
])
let window;
app.once('ready', () => {
window = new BrowserWindow({
width: 300,
height: 200
});
window.loadURL('about:blank')
window.setTouchBar(touchBar);
})
// Quit when all windows are closed and no other one is listening to this.
app.on('window-all-closed', () => {
app.quit();
});
我这里也有示例存储库。您可以替换我main.js
在项目中给定的内容以进行尝试。我的电子版是1.6.4
,节点版是7.4.0