Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

enter image description here

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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]];

Revisions: 1st 2nd

share|improve this answer
    
1) those buttons, it is safer to put them in Row[] instead of multiplying them. 2) from where do you know how to work with EventHandlerTag? –  Kuba Aug 8 '13 at 6:08
    
I just ran ToBoxes@Graphics[EventHandler[Circle[]...]] to see the box form of the EventHandler. Yes it could change between versions. –  Liam William Aug 8 '13 at 6:34
    
@Kuba I just posted a different approach entirely that no longer uses EventHandlerTag. –  Liam William Aug 8 '13 at 6:40
    
I understand that you are creating hyperlinks by your own with EventHandler, not with Hyperlink, am I right? –  Kuba Aug 8 '13 at 6:46
    
@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] and EventHandler[w, "MouseClicked" :> x, y] which is why there are 2 replaces. Well it is definitely a lot shorter then it used to be. –  Liam William Aug 8 '13 at 6:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.