Hey all,
I mentioned before that I’m building a replacement for TiddlyMap. It’s going to be awesome. More extensible and hackable, more lightweight, and it won’t be tied to any one graphing engine, but to as many as we want (currently memgraph/orb and vis-network).
But I’m at a design crossroads, and I’d like to take the choice the gels best with Tiddlywiki best practices. Currently, you can attach actions to nodes, and to the canvas as a whole, like this:
<$graph>
<$action-to-occur-on-canvas-dbclick />
<$list filter="[tag[myNodes]]">
<$node>
<$action-to-occur-on-node-dbclick />
</$node></$list></$graph>
It already works like a charm. You can even use this to add and remove nodes from the graph, BUT there are more things you can do to nodes, edges, and the graph, such as right clicks, hovers, blurs, drags, etc… So I need to figure out a way to differentiate actions based on event type. If I were to follow the lead of the <$checkbox>, <$range>, and <$link> widgets, I’d do this:
<$graph actions="""<$action-to-occur-on-canvas-dbclick />""" >
<$list filter="[tag[myNodes]]">
<$node
actions="""<$action-to-occur-on-node-dbclick />"""
actionsDrag="""<$action-record-new-node-location />"""
actionsHover="""<$action-delay>
<$action-show-tooltip>{{TooltipContent}}</$action-show-tooltip>
</$action-delay>"""
actionsBlur="""<$action-hide-tooltip />""" >
</$node></$list></$graph>
This would work. It’s simple, intuitive, and in line with many existing widgets. But it’s also limiting, and given the advent of the \widget
, and widgets like <$list-join>, <$list-empty> to replace attributes, and from my talks with @jeremyruston, It seems like TiddlyWiki is now discouraging putting wikitext in attributes. So I was considering introducing a new widget like “<$actions>” to allow syntax like this:
<$graph>
<$actions for="doubleclick"><$action-to-occur-on-canvas-dbclick /></$actions>
<$list filter="[tag[myNodes]]">
<$node>
<$actions for="doubleclick"><$action-to-occur-on-node-dbclick /></$actions>
<$actions for="drag"><$action-record-new-node-location /></$actions>
<$actions for="hover">
<$action-delay>
<$action-show-tooltip>{{TooltipContent}}</$action-show-tooltip>
</$action-delay>
</$actions>
<$actions for="blur"><$action-hide-tooltip /></$actions>
</$node></$list></$graph>
So this syntax is more verbose, but it keeps all wikitext in the main parseTreeNode, plus it allows for packaging of features more easily. For instance, all the infrastructure needed just to have tooltips could be wrapped like this:
\widget $node.tooltip()
<$actions for="hover">
<$action-delay>
<$action-show-tooltip>
<$slot $name="ts-raw">
</$action-show-tooltip>
</$action-delay>
</$actions>
<$actions for="blur">
<$action-hide-tooltip />
</$actions>
\end
Tooltips are actually even more complicated than that. (What if they unhover before tooltip appears, etc…), which is why it’s important to be able to wrap functionality like that. You can’t do something like this if actions are done in attributes because this “action package” spans multiple types of events. This is one example, but there are others where actions in parseTrees are more useful for compound behavior (such as a create/edit/delete tiddlers action package). But it’s just so verbose.
Maybe I’m trying to be too extensible, and tooltips should be baked in behavior, and doubleclicks the only actions graph objects care about?
Is this idea too un-TiddlyWiki, or is it in line with the direction TiddlyWiki is going? I really want this plugin to adhere to TiddlyWiki’s vision, so I’d love to hear your thoughts. @pmario, @saqimtiaz, you guys seem in particular to have a good sense of TW’s direction.
-Flibbles