Share JSXGraph: example "Click on element"

JSXGraph
Share JSXGraph: example "Click on element"
This website is a beta version. The official release will be in **2024**.

Click on element

JSXGraph does not watch for `click` events. Instead, the `up` event could be used. With this e.g. a right click event on an element could be realized.
// Define the id of your board in BOARDID

const board = JXG.JSXGraph.initBoard(BOARDID, {
    boundingbox: [-5, 5, 5, -5],
    axis: true
});

var point = board.create('point', [1, 1], {
    size: 10
});

var txt = board.create('text', [-3, 3, 'Right click'], {
    fontSize: 24,
    visible: false
});

point.on('up', (evt) => {
    // Check for right button
    if (evt.button === 2) {
        // Show text
        txt.setAttribute({
            visible: true
        });
        // Hide text after two seconds
        setTimeout(() => txt.setAttribute({
            visible: false
        }), 2000);
    }
});