Hello everyone.
I am working on a package dealing with a specific type of object that has a visual representation, so I'm trying to reproduce the behavior of the Graph objects in Mathematica. By that, I mean that when an output cell contains a graph it's visually represented, and you can embed this visual representation into your code for further computing (instead of having the full list of edges).
So far, this is what I have done.
myObject /: MakeBoxes[myObject[data_], StandardForm] := TemplateBox[
{
myObject[data],
ToBoxes@Deploy@visualRepresentation[myObject[data]]
},
"myObject",
DisplayFunction :> (#2 &),
InterpretationFunction :> (#1 &)]
It's working properly except that I cannot copy-paste the visual representation and it be evaluated as the object, and I cannot evaluate an output cell. However, I can use % to refer to the output and then it works. Anyone would know how to achieve that?