I am trying to write a way that will do certain events depending on what screen is showing.
What happens so far is that the screen will change in accordance to a click, but when you try to do the key presses associated with that screen, they won't respond. I think the events are being passed to the old screen that is being shown. Is there an option or way to fix this?
My code thus sees if you click within certain coordinates (works, but not shown in simplified code below), then changes what it is showing. The arrow key pressing that corresponds to the new screen does not happen, unless I reevaluate the EventHandler block of code. Code is below:
displaying = True;
start[] :=
If[displaying,
Show[firstScreen],
Show[secondScreen]
]
EventHandler[
Dynamic[start[]], {"UpArrowKeyDown" :> (If[!displaying, Print["up press"]]),
"DownArrowKeyDown" :> (If[!displaying, Print["down press"]]),
"MouseClicked" :> (If[displaying,
displaying = False])
}]
NotebookEventActions
$\endgroup$