Forge Viewer 自定义 Combox/ComboButton
Forge Viewer Custom Combox/ComboButton
您好,我正在尝试添加自定义组合框,这是我的代码
addCustomCombox(parentCtrl: any) {
//create combox
const comboButton = new Autodesk.Viewing.UI.ComboButton('buildings');
comboButton.setToolTip('buildings');
//create button
var button1 = new Autodesk.Viewing.UI.Button('show-env-bg-button');
button1.onClick = function (e) {
alert('test');
};
button1.addClass('show-env-bg-button');
button1.setToolTip('Show Environment');
//attach button to combox
comboButton.addControl(button1);
parentCtrl.addControl(comboButton)
}
但是我在 comboButton.addControl()
上收到一个错误,它说需要 0 个参数。我检查了节点模块,这是 ComboButton
的功能
class ComboButton extends Button {
constructor(id: string, options?: object);
addControl(): void;
restoreDefault(): void;
saveAsDefault(): void;
}
addControl
不接受任何参数。那么如何创建自定义组合框呢?非常感谢任何帮助。谢谢
**Whosebug 参考:
你使用打字稿定义吗?
修改如下:
class ComboButton extends Button {
constructor(id: string, options?: object);
addControl(button: any): void;
restoreDefault(): void;
saveAsDefault(): void;
}
您好,我正在尝试添加自定义组合框,这是我的代码
addCustomCombox(parentCtrl: any) {
//create combox
const comboButton = new Autodesk.Viewing.UI.ComboButton('buildings');
comboButton.setToolTip('buildings');
//create button
var button1 = new Autodesk.Viewing.UI.Button('show-env-bg-button');
button1.onClick = function (e) {
alert('test');
};
button1.addClass('show-env-bg-button');
button1.setToolTip('Show Environment');
//attach button to combox
comboButton.addControl(button1);
parentCtrl.addControl(comboButton)
}
但是我在 comboButton.addControl()
上收到一个错误,它说需要 0 个参数。我检查了节点模块,这是 ComboButton
class ComboButton extends Button {
constructor(id: string, options?: object);
addControl(): void;
restoreDefault(): void;
saveAsDefault(): void;
}
addControl
不接受任何参数。那么如何创建自定义组合框呢?非常感谢任何帮助。谢谢
**Whosebug 参考:
你使用打字稿定义吗?
修改如下:
class ComboButton extends Button {
constructor(id: string, options?: object);
addControl(button: any): void;
restoreDefault(): void;
saveAsDefault(): void;
}