View in #cornerstone3d on Slack
@Christopher_Nagy: Hi all, is there any option / configuration to disable the tool-specific cursors, that are set to the viewport element’s style tag in the HTML? I would like to use another cursor, but it keeps overridden by the one from cornerstone3D. Example: https://www.cornerstonejs.org/live-examples/petct
@Alireza_Sedghi: Hmmm, i haven’t touched this part for a long time, but i remember it was possible
@Christopher_Nagy: Okay, can you give me some hint where to look for it?
@Alireza_Sedghi: I guess this
import { setElementCursor } from './elementCursor';
import MouseCursor from './MouseCursor';
import SVGMouseCursor from './SVGMouseCursor';
/**
* Set the cursor for an HTML element. cursorNames can be either
* cornerstone3DTools cursors or standard cursors.
*
* @param element - The element to set the cursor on.
* @param cursorName - The name of the cursor to set. This can be
* any cursor name either Cornerstone-specific cursor names or the standard
* CSS cursor names.
*/
function setCursorForElement(
element: HTMLDivElement,
cursorName: string
): void {
let cursor = SVGMouseCursor.getDefinedCursor(cursorName, true);
if (!cursor) {
cursor = MouseCursor.getDefinedCursor(cursorName);
}
if (!cursor) {
console.log(
`Cursor ${cursorName} is not defined either as SVG or as a standard cursor.`
);
cursor = MouseCursor.getDefinedCursor(cursorName);
}
setElementCursor(element, cursor);
}
export default setCursorForElement;
but seems like it is for eleemnt
maybe we need one for tool?
actually this one
static setDefinedCursor(name: string, cursor: MouseCursor): boolean {
if (cursor instanceof MouseCursor) {
const definedCursors = getDefinedCursors(
// @ts-ignore
MouseCursor as Record<symbol, Map<string, MouseCursor>>,
DEFINED_CURSORS
);
definedCursors.set(name, cursor);
return true;
}
return false;
}
you can override the previous name i guess
use that
@Christopher_Nagy: I will try it, thanks!