OK, I’ve implemented part of this in a single function. All three arguments are needed, but if supplied as an empty string value, a default is used. For the new/old link types it is *untitled
and for the IDString is is this
. Some of the tests also need a link type called hidden
. Add a new link type to your document, call it “hidden” and un-tick the ‘visible’ label (you can leave the label option as invisible links don’t draw their label). The function is:
function fSwitchLink(iOldType:string, iNewType:string, iIDStr:string){
var:string vNote;
if(iIDStr==""){
vNote="this";
}else{
vNote=iIDStr;
};
var:string vOldType;
if(iOldType==""){
vOldType="*untitled";
}else{
vOldType=iOldType;
};
var:string vNewType;
if(iNewType==""){
vNewType="*untitled";
}else{
vNewType=iNewType;
};
eachLink(aLink,vNote){
if(aLink["type"]==vOldType){
aLink["type"]=vNewType;
}
};
To change the selected note’s untitled links to ‘hidden’ (using the optional empty defaults):
fSwitchLink("","hidden","");
To change the selected note’s ‘agree’ links to ‘disagree’ (using the optional empty defaults):
fSwitchLink("agree","disagree",$IDString);
By giving the $IDString of a different note, either as a literal string value or using an offset reference, e.g. $IDString(“Some note”), links for a different note can be altered.
Note that you can only toggle the link type of a pair of types, rather than all types. If you be easy to write a function to loop trough all used link types (we can get those from the link-types
key of document(). Harder is storing original per-link differing link types, especially if the same two notes are linked by links of multiple types. IOW, I suggest the latter scenerio is not noew to plan for.
Anyway, here is the test doc for the above: linktype-swap.tbx (268.6 KB)
The TBX has 6 stamps (3 matched reversing pairs) for you to try out by switching to the Map view tab, selecting note ‘aa’ and applying a stamp.
Note that this method works by changing a given links link type and not the links properties. Individual links links cannot be altered using action code (though appleScript is a possibility, though i’ve not tested this).
However, I’m not sure the above is what @andreas was asking for. Instead I think he wanted a map-scoped single toggle for all link types (links and stubs). That basically alters the visible
property of links as opposed to altering the link type of links. On a busy map there may be a lot of links and rather than fiddle with each, if there were a boolean switch that was checked at the point where the map starts to draw links I suspect that—whilst requiring a new feature (a system boolean?)—it might when done result in less work for the app to ‘just’ suppress links on a given map. FWIW, this sort of approach was what was in mind when i mentioned it when describing a circular map layout pattern the other day (see this thread).