# Want to add button in inner node

**URL:** <https://forum.graphviz.org/t/want-to-add-button-in-inner-node/938>\
**Category:** Help\
**Created:** [December 8, 2021, 4:09pm UTC](https://forum.graphviz.org/t/want-to-add-button-in-inner-node/938 "2021-12-08T16:09:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fahadali](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@fahadali](https://forum.graphviz.org/u/fahadali)\
**Post date:** [December 8, 2021, 4:09pm UTC](https://forum.graphviz.org/t/want-to-add-button-in-inner-node/938/1 "2021-12-08T16:09:44Z")

</div>

I want to add a button and clickable event inside the node is there any way to do it?

```auto
digraph structs {
    node [shape=plaintext]
    struct1 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
  <TR><TD>left</TD><TD PORT="f1">mid dle</TD><TD PORT="f2">right</TD></TR>
</TABLE>>];
    struct2 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
  <TR><TD PORT="f0">one</TD><TD>two</TD></TR>
</TABLE>>];
    struct3 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
  <TR>
    <TD ROWSPAN="3">hello<BR/>world <BUTTON TYPE="BUTTON" ONCLICK="callBack()">HELLO BUTTON</BUTTON> </TD>
    <TD COLSPAN="3">b</TD>
    <TD ROWSPAN="3">g</TD>
    <TD ROWSPAN="3">h</TD>
  </TR>
  <TR>
    <TD>c</TD><TD PORT="here">d</TD><TD>e</TD>
  </TR>
  <TR>
    <TD COLSPAN="3">f</TD>
  </TR>
</TABLE>>];
    struct1:f1 -> struct2:f0;
    struct1:f2 -> struct3:here;
}

```

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [December 8, 2021, 7:52pm UTC](https://forum.graphviz.org/t/want-to-add-button-in-inner-node/938/2 "2021-12-08T19:52:08Z")

</div>

Short answer - Graphviz does not support this  
Longer answers, if you are willing to fiddle around:

- If you can use non-HTML records, Marc’s answer may work for you (uses class attribute): [Can I make a Digraph node interactive](https://forum.graphviz.org/t/can-i-make-a-digraph-node-interactive/503)
- If HTML-record shape is necessary, maybe this “kludge” will work:
  - use/abuse the **href** attribute to insert a version of your javascript code
  - postprocess the SVG output to fix the href-related text (using awk, python, sed, …)

```auto
digraph structs {
    node [shape=plaintext]
    struct3 [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
  <TR>
    <TD ROWSPAN="3" href="!!alert('done')">hello<BR/>world</TD>
    <TD COLSPAN="3">b</TD>
    <TD ROWSPAN="3">g</TD>
    <TD ROWSPAN="3" href="!!alert('hello there')">h</TD>
  </TR>
</TABLE>>];
}

```

postprocessing:

```auto
gawk '
  /href="!!/{
    sub("><.*!!"," onclick=\"");
    sub(/xlink[^>]*/,"")
  }
 $0=="</a>"{next}
{print}' myfile.svg

```

Ugly, but seems to work

---

<div class="post-metadata">

**Author:** ![fahadali](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@fahadali](https://forum.graphviz.org/u/fahadali)\
**Post date:** [December 9, 2021, 5:19pm UTC](https://forum.graphviz.org/t/want-to-add-button-in-inner-node/938/3 "2021-12-09T17:19:09Z")

</div>

i am running this but not working:

```auto
digraph G {
                                    //ratio = fill;
                                    node [style=filled];
                                    size="8"
                                    node [shape = rectangle];
                                    
                    subgraph cluster_A {
                      color=blue;
                      node [shape=rectangle,style=filled,color=cadetblue2];
                      Process_2 -> Process_3 ;
                      label = "A";
                    }
                      
                    subgraph cluster_B {
                      color=blue;
                      node [shape=rectangle,style=filled,color=mediumpurple2];
                      Process_4 -> Process_5 -> Process_6 ;
                      label = "B";
                    }
                      
                    subgraph cluster_C {
                      color=blue;
                      node [shape=rectangle,style=filled,color=olivedrab2];
                      Process_7 -> Process_8 -> Process_9 ;
                      label = "C";
                    }
                      
                        "Process_1"
                      
                        "Process_2"
                      
                          Process_1 [class="Process_1"]  
                          Process_3 [class="clickme"]
                          Process_1 -> Process_3;
                          
                          
                          Process_2 [class="Process_2"]  
                          Process_3 [class="clickme"]
                          Process_2 -> Process_3;
                          
                          
                          Process_3 [class="Process_3"]  
                          Process_4 [class="clickme"]
                          Process_3 -> Process_4;
                          
                          
                          Process_2 [class="Process_2"]  
                          Process_4 [class="clickme"]
                          Process_2 -> Process_4;
                          
                          
                          Process_4 [class="Process_4"]  
                          Process_5 [class="clickme"]
                          Process_4 -> Process_5;
                          
                          
                        "Process_6"
                      
                        "Process_7"
                      
                          Process_5 [class="Process_5"]  
                          Process_8 [class="clickme"]
                          Process_5 -> Process_8;
                          
                          
                        "Process_9"
                      
                          Process_9 [class="Process_9"]  
                          New_XYZ [class="clickme"]
                          Process_9 -> New_XYZ;
                          
                          
  }

```

```auto
 d3.select('#graph').graphviz().renderDot(graphStatic)
                  .selectAll(".clickme")
                  .on("renderStart", evt => console.log("Hello and welcome!"));

```
