Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- linksEnabled = True;
- Print[Button["Disable/Enable Hyperlinks",
- NotebookFind[EvaluationNotebook[], "MyGraphic", All, CellTags,
- AutoScroll -> False];
- (* NotebookLocate["MyGraphic"];*)
- temp = NotebookRead[EvaluationNotebook[]];
- NotebookWrite[EvaluationNotebook[], If[linksEnabled,
- linksEnabled = False;
- Replace[temp,
- EventHandlerTag[{"MouseClicked" :> x__, y___}] ->
- EventHandlerTag[{"MouseClicked2" :> x, y}], \[Infinity]]
- ,
- linksEnabled = True;
- Replace[temp,
- EventHandlerTag[{"MouseClicked2" :> x__, y___}] ->
- EventHandlerTag[{"MouseClicked" :> x, y}], \[Infinity]]
- ]]
- ] Button["Edit Hyperlink For Object", Function[
- Module[{ret},
- shape = NotebookRead[SelectedNotebook[]];
- If[Head[shape] == GraphicsBox,
- MessageDialog["Unable to add Hyperlink to GraphicsBox"];
- Return[], Null];
- NotebookWrite[EvaluationNotebook[],
- TagBox[shape, "MouseClickedUniqueId314"]];
- (* Prevents adding duplicate links *)
- NotebookFind[EvaluationNotebook[], "MyGraphic", All, CellTags,
- AutoScroll -> False];
- (* NotebookLocate["MyGraphic"];*)
- temp = NotebookRead[EvaluationNotebook[]];
- text = If[linksEnabled, "MouseClicked", "MouseClicked2"];
- NotebookWrite[EvaluationNotebook[],
- temp /.
- TagBox[TagBox[shape_, "MouseClickedUniqueId314"],
- EventHandlerTag[t___]
- ] -> TagBox[shape, EventHandlerTag[t]] /.
- TagBox[shape_, "MouseClickedUniqueId314"]
- ->
- TagBox[shape,
- EventHandlerTag[{text :>
- FrontEndExecute[{NotebookLocate[{URL[
- FindFile["./Costs.nb"]], None}]}],
- PassEventsDown -> Automatic, PassEventsUp -> True}]
- ]
- ];
- ]
- ]
- ]];
- CellPrint[Cell[BoxData[
- ToBoxes[Graphics[{Circle[]}, ImageSize -> {100, Automatic}]]
- ], "Output", CellTags -> "MyGraphic"]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement