I'm trying to "automate" generation of new bookmark from page region selection.
I'll raise 3 questions here...
I'd like a new bookmark to be added upon selecting a region on a page - without the need to also execute "add new bookmark".
So, in images, I want to have the same result as the following - but last step from code:
Step 1:
Step 2:
Step 2 (another way - same result - using Bookmarks Pane):
Question 1: how to differentiate between tool.selPageRegions and tool.selPageRegions.cut - tool activated by "cmd.tool.selPageRegions.cut" ?
In Q2 ActiveTool is "selection.pageRect" even if command executed was cmd.tool.selPageRegions.cut or cmd.tool.selPageRegions.delete.
Question 2:
My code idea so far (pseudo):
Code: Select all
On e.docSelection.changed
doc = IPXV_Document(pFrom);
If doc.ActiveSel.ID = "selection.pageRect"
If doc.ActiveTool.ID = "tool.selPageRegions"
{
InstUI.CmdManager.ExecCmd('cmd.bookmarksView.new', doc.ActiveView.Obj);
doc.ActiveSel.Clear;
pEvent.Handled = true;
}
With ExecCmd - I have stack overflow as ExecCmd re-raises e.docSelection.changed (selection.bookmarks) and this code runs in circles.
Actual question: what other options do I have to create bookmark (from selection) and clear selection?
Question 3:
I have noticed the following: if the snapshot tool is activated and some snapshot taken (so there is snapshot-selection) - activating "Select Page Region" (from UI) would raise e.docSelection.changed AND ActiveSel.ID would be "selection.pageRect" AND ActiveTool.ID = "tool.selPageRegions" - BUT the selection would still be from the Snapshot tool - so selection from snapshot not cleared before event happens.
-žarko