pyvis icon indicating copy to clipboard operation
pyvis copied to clipboard

Can I make some kind of handler for onmouse click event?

Open BlackS52 opened this issue 3 years ago • 4 comments

Tried to find something but can't. Can you advise is it possible in pyvis to make a handler for OnMouse event ? I really need it or something like this to make my own handler for On Mouse click, Drag, and etc.

Thanks in advance.

BlackS52 avatar Oct 14 '22 15:10 BlackS52

I am also very interested in this

llvll0hsen avatar Apr 13 '23 07:04 llvll0hsen

did u find something?

Y3g9r avatar Jan 09 '24 12:01 Y3g9r

Unfortunately no. Couldn't find anything. It looks like that feature was on developing that time. Don't know the current state.

BlackS52 avatar Jan 09 '24 12:01 BlackS52

hi, I just find a solution, you can use custom js and replace it after you generate the html

    # Generate HTML with custom JavaScript for double-click event
    net_html = net.generate_html()
    custom_js = """
    <script type="text/javascript">
        network.on("doubleClick", function (params) {
            if (params.nodes.length > 0) {
                var nodeId = params.nodes[0];
                var node = nodes.get(nodeId);
                console.log("Node double-clicked:", node.label);
                alert("Node double-clicked: " + node.label);
            }
        });
    </script>
    """

    # Embed the custom JavaScript in the HTML
    net_html = net_html.replace("</body>", custom_js + "</body>")
    ```

CharlieDreemur avatar Jul 23 '24 03:07 CharlieDreemur