Code Monkey home page Code Monkey logo

Comments (4)

stefanloerwald avatar stefanloerwald commented on August 16, 2024

Hi @rad765,

since the diagram component layers a div layer above an svg layer, where interaction with the svg layer is necessary for moving nodes, it is not possible to make nodes clickable by applying an onclick callback on the node component. However, it is possible by making the nodes' content clickable:

<RectangleNode Context="node">
    <div @onclick="(_) => { clicked = node; }" style="pointer-events: all;">Node content</div>
</RectangleNode>

Note the pointer-events: all;, which is required, because the node contents are in a div that generally doesn't receive any pointer events.
When you want nodes to be movable AND clickable, I recommend adding a margin to the node content.

<RectangleNode Context="node">
    <div @onclick="(_) => { clicked = node; }" style="pointer-events: all; margin: 1em; background: darkgray;">Node content (movable. To move, grab the node outside the text area)</div>
</RectangleNode>

from blazor.diagrams.

rad765 avatar rad765 commented on August 16, 2024

Thank you. I don't realy want the nodes and links to be both clickable an movable, I rather think of two modes for the diagram, (1: "edit" mode where one can create new nodes and move around and draw links, and 2: a non Edit mode where the nodes are clickable.), I will play around with your suggestion, and see if it works.

That brings me to another question, what about JSON serializaion and deserialization of Nodes and Links so that the diagram can be saved and reloaded?

from blazor.diagrams.

stefanloerwald avatar stefanloerwald commented on August 16, 2024

I'm afraid there's no (de-)serialization feature in the library. You can use the events to listen to changes in the diagram. If you need a more first-class support for this I'm happy to look at a pull request, if you'd like to implement it.

from blazor.diagrams.

rad765 avatar rad765 commented on August 16, 2024

:-) I will take a look on it, to see if I'm able to do it. Thanks

from blazor.diagrams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.