Overclock
Overclock
Help: Error when trying to add a SceneControlButton
Hello, I ran into an error when trying to add a SceneControlButton. Code:
Hooks.on("getSceneControlButtons", getSceneControlButtons);

function getSceneControlButtons(controls) {
if (canvas == null) {
return;
}
controls.push({
name: "markers",
title: "Markers",
icon: "fa-solid fa-location-pin",
layer: "markers",
visible: true,
tools: [
{
name: "create-marker",
title: "Create Marker",
icon: "fa-solid fa-location-pin",
button: true,
},
],
activeTool: "marker",
});
}
Hooks.on("getSceneControlButtons", getSceneControlButtons);

function getSceneControlButtons(controls) {
if (canvas == null) {
return;
}
controls.push({
name: "markers",
title: "Markers",
icon: "fa-solid fa-location-pin",
layer: "markers",
visible: true,
tools: [
{
name: "create-marker",
title: "Create Marker",
icon: "fa-solid fa-location-pin",
button: true,
},
],
activeTool: "marker",
});
}
The button is added, but when clicked I get an error in the console:
Uncaught TypeError: Cannot read properties of undefined (reading 'activate')
at SceneControls._onClickLayer (foundry.js:81634:42)
at HTMLLIElement.dispatch (jquery.min.js:2:40035)
at v.handle (jquery.min.js:2:38006)
Uncaught TypeError: Cannot read properties of undefined (reading 'activate')
at SceneControls._onClickLayer (foundry.js:81634:42)
at HTMLLIElement.dispatch (jquery.min.js:2:40035)
at v.handle (jquery.min.js:2:38006)
I am at my wit's end. Any and all help would be appreciated.
5 replies