I have been looking for a possibly difficult answer to a simple question. I would like to be able to highlight paths on a TikZ picture. I would like to highlight these paths by clicking on them and at each step retain the previous steps.

For instance, in the MWE below, I would like to start with the 4 empty squares, and have the color appear on each of them by clicking on it. And considering that any path can be chosen. I guess I can do it by using {hyperref} and identify all the possible ways, but there must be some easier way I am sure.

Any idea?

```
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{box1/.style={draw=black, thick, rectangle,rounded corners, minimum height=2cm, minimum width=2cm}}
\begin{document}
\begin{tikzpicture}
\node[box1, fill=white] (c1) {1};
\node[box1, fill=white, right=1cm of c1] (c2) {2};
\node[box1, fill=white, below=1cm of c2] (c3) {3};
\node[box1, fill=white, left=1cm of c3] (c3) {4};
\node[box1, fill=red, right=5cm of c1] (c21) {1};
\node[box1, fill=blue, right=1cm of c21] (c22) {2};
\node[box1, fill=orange, below=1cm of c22] (c23) {3};
\node[box1, fill=green, left=1cm of c23] (c23) {4};
\end{tikzpicture}
\end{document}
```

## Best Answer

This could be automated even further, and it would be nice if the hyperlinks were the same size as the nodes, but it shows - I think - the main idea.

Each possible configuration is generated, and each unfilled square is linked to the next appropriate configuration. By labelling the configurations according to which squares are filled, it is very easy to sort out the paths in the graph linking the configurations.

Update 2013-08-31This version allows for two-way clicking, so a coloured node is a link to the uncoloured one and vice versa. It actually makes the code a smidgeon simpler. To offset that, I've included Jake's excellent code for making the entire node clickable (and used`hidelinks`

to hide the red boxes).