I have a Graphics
element which I edit with Drawing Tools. I have determined a technique using NotebookWrite
to add hyperlinks to the selected shape. My question is, how might I disable and enable the hyperlinks so that I can edit the current shape and surround shapes without invoking the links. Other usability ideas are welcome
$\begingroup$
$\endgroup$
Add a comment
|
$\begingroup$
$\endgroup$
7
After messing around with several techniques I decided the CellTags
was overly complicated and didn't work consist enough, so here is simplified version. Simply pass the Graphics element in as an argument to get alternative output.
disableClicks[i_] := Replace[i, {
EventHandler[w___, {"MouseClicked" :> x___, y___}, z___] ->
EventHandler[w, {"MouseClicked2" :> x, y}, z],
EventHandler[w___, "MouseClicked" :> x___, z___] ->
EventHandler[w, {"MouseClicked2" :> x}, z]
}, \[Infinity]];
enableClicks[i_] := Replace[i, {
EventHandler[w___, {"MouseClicked2" :> x___, y___}, z___] ->
EventHandler[w, {"MouseClicked" :> x, y}, z],
EventHandler[w___, "MouseClicked2" :> x___, z___] ->
EventHandler[w, {"MouseClicked" :> x}, z]
}, \[Infinity]];
-
$\begingroup$ 1) those buttons, it is safer to put them in
Row[]
instead of multiplying them. 2) from where do you know how to work withEventHandlerTag
? $\endgroup$ – Kuba♦ Aug 8 '13 at 6:08 -
$\begingroup$ I just ran
ToBoxes@Graphics[EventHandler[Circle[]...]]
to see the box form of the EventHandler. Yes it could change between versions. $\endgroup$ – William Aug 8 '13 at 6:34 -
$\begingroup$ @Kuba I just posted a different approach entirely that no longer uses
EventHandlerTag
. $\endgroup$ – William Aug 8 '13 at 6:40 -
$\begingroup$ I understand that you are creating hyperlinks by your own with
EventHandler
, not withHyperlink
, am I right? $\endgroup$ – Kuba♦ Aug 8 '13 at 6:46 -
$\begingroup$ @Kuba I didn't think of that. I guess you or I could further extend the code. Early I had to take into account
EventHandler[w, {"MouseClicked" :> x, y}, z]
andEventHandler[w, "MouseClicked" :> x, y]
which is why there are 2 replaces. Well it is definitely a lot shorter then it used to be. $\endgroup$ – William Aug 8 '13 at 6:53