Whenever you add a figure to the active layer of a document, that figure
will get automatically selected for you in the Canvas when you commit$ your
transaction.
doc.add( figures );doc.commit$(); // Triggers canvas.selectedFigures( figures );
If at any point of the transaction you change the selection by hand,
then auto selection will not kick in for newly selected figures. The
following transaction will leave Canvas without any selected figures.
doc.add([ figure, border ]);doc.selectedFigures( figure );doc.commit$(); // Manual selection, border is not selected
With this simple scheme, figure auto selection will do what is expected
for almost every transaction you will ever write. There are some corner
cases where you will not want want automatic selection to kick in for a
given transaction. If you find yourself in that case just call:
canvas.keepSelection();doc.add(figure);doc.commit$(); // Auto selection disabled for this transaction
You can call this function at any point before the transaction commit$.
If you want to disable the feature altogether for all your transactions
you can use:
canvas.autoSelection(false);
These is not recommended, because the app will need to select the newly
added figures by hand in each transaction.