pyvis
pyvis copied to clipboard
Can I make some kind of handler for onmouse click event?
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.
I am also very interested in this
did u find something?
Unfortunately no. Couldn't find anything. It looks like that feature was on developing that time. Don't know the current state.
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>")
```