# Change on click in beamer

Is the following possible using the beamer class:

1. You have two images image1.jpg and image2.jpg
2. You define two "clickable" areas (a1 and a2) of your frame which you can overlay by an picture or tikzimage to simulate fancy buttons
3. If you click on a1 image1.jpg is shown, if you click on a2 image2.jpg is shown (i.e. image1 is replaced by image2).

More generally I need this for n areas and n pictures.

Here is an example. It doesn't work, since it is mainly pseudo-code and just want's to illustrate what I want. This example doesn't imply that the solution should be made of tikz or that it should be the same syntax. All what I want is what I described above.

\documentclass{beamer}

\usepackage[draft]{graphicx}

\usepackage{tikz}

\usepackage{boolexpr}

\def\show{1}

\begin{document}
\begin{frame}

\switch
\case{\show == 1}
\includegraphics[width=0.9\linewidth]{test1}
\case{\show == 2}
\includegraphics[width=0.9\linewidth]{test2}
\otherwise
\endswitch

\begin{tikzpicture}
\node[onclick={\show = 1}] at (0,0) {\includegraphics[width=0.5cm]{Button1}};
\node[onclick={\show = 2}] at (0,2) {\includegraphics[width=0.5cm]{Button2}};
\end{tikzpicture}
\end{frame}
\end{document}

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. You can use the mwe package to use the dummy images A,B,C by using \includegraphics{example-image-a,b,c} which loads graphicx package automaticaly. – percusse Oct 31 '12 at 10:48
Not at all. Setting up a problem is the worst part about working on an answer. Providing a basis makes it quite practical to copy/paste a code and immediately try some things on it. – percusse Oct 31 '12 at 10:57
Thank you for the MWE – percusse Oct 31 '12 at 11:34
One thing to bear in mind with this is the question of onward and backward navigation. Not all PDF viewers have "back" and "forward" buttons for when you move around using hyperlinks. So you should also have explicit "next page" and "previous page" links to get you out of your image-changing system. – Loop Space Oct 31 '12 at 11:38
Can't really see what you are trying to do but will @PaulGaborit's ocgx package help? See demo file there. – hpesoj626 Dec 8 '12 at 11:10

Using hpesoj626's suggestion of the ocgx package, you can do this (but it doesn't use your interface):

\documentclass{beamer}

\usepackage{graphicx}
\usepackage{ocgx}
\usepackage{mwe}
\usepackage{tikz}

\begin{document}
\begin{frame}
\begin{tikzpicture}
\node at (0,0) {\begin{ocg}{Image A}{ocg1}{1}\actionsocg{}{ocg2}{ocg1}{\includegraphics[width=0.5cm]{example-image-a}}\end{ocg}};
\node at (0,2) {\begin{ocg}{Image B}{ocg2}{0}\actionsocg{}{ocg1}{ocg2}{\includegraphics[width=0.5cm]{example-image-b}}\end{ocg}};
\end{tikzpicture}
\end{frame}
\end{document}


There is also a tikz library provided by ocgx that may be of interest; it is documented in the ocgx manual.

-