Advertisement
Guest User

Untitled

a guest
Aug 8th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. linksEnabled = True;
  2. Print[Button["Disable/Enable Hyperlinks",
  3. NotebookFind[EvaluationNotebook[], "MyGraphic", All, CellTags,
  4. AutoScroll -> False];
  5. (* NotebookLocate["MyGraphic"];*)
  6. temp = NotebookRead[EvaluationNotebook[]];
  7. NotebookWrite[EvaluationNotebook[], If[linksEnabled,
  8. linksEnabled = False;
  9. Replace[temp,
  10. EventHandlerTag[{"MouseClicked" :> x__, y___}] ->
  11. EventHandlerTag[{"MouseClicked2" :> x, y}], \[Infinity]]
  12. ,
  13. linksEnabled = True;
  14. Replace[temp,
  15. EventHandlerTag[{"MouseClicked2" :> x__, y___}] ->
  16. EventHandlerTag[{"MouseClicked" :> x, y}], \[Infinity]]
  17. ]]
  18. ] Button["Edit Hyperlink For Object", Function[
  19. Module[{ret},
  20. shape = NotebookRead[SelectedNotebook[]];
  21. If[Head[shape] == GraphicsBox,
  22. MessageDialog["Unable to add Hyperlink to GraphicsBox"];
  23. Return[], Null];
  24. NotebookWrite[EvaluationNotebook[],
  25. TagBox[shape, "MouseClickedUniqueId314"]];
  26. (* Prevents adding duplicate links *)
  27. NotebookFind[EvaluationNotebook[], "MyGraphic", All, CellTags,
  28. AutoScroll -> False];
  29. (* NotebookLocate["MyGraphic"];*)
  30. temp = NotebookRead[EvaluationNotebook[]];
  31. text = If[linksEnabled, "MouseClicked", "MouseClicked2"];
  32. NotebookWrite[EvaluationNotebook[],
  33. temp /.
  34. TagBox[TagBox[shape_, "MouseClickedUniqueId314"],
  35. EventHandlerTag[t___]
  36. ] -> TagBox[shape, EventHandlerTag[t]] /.
  37. TagBox[shape_, "MouseClickedUniqueId314"]
  38. ->
  39. TagBox[shape,
  40. EventHandlerTag[{text :>
  41. FrontEndExecute[{NotebookLocate[{URL[
  42. FindFile["./Costs.nb"]], None}]}],
  43. PassEventsDown -> Automatic, PassEventsUp -> True}]
  44. ]
  45. ];
  46.  
  47. ]
  48. ]
  49. ]];
  50. CellPrint[Cell[BoxData[
  51. ToBoxes[Graphics[{Circle[]}, ImageSize -> {100, Automatic}]]
  52. ], "Output", CellTags -> "MyGraphic"]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement