PDFNet [Android]: Creating a custom Tool loop continuously


I’ve create a class that extends pdftron.PDF.Tools.ToolManager.
In this class, I’ve override the method createTool In this method I would like to create a custom tool in some special cases.
I’ve tried
MyTool myTool = new MyTool();
return myTool;

where MyTool is a class that implements Tool.

Why it loops continuously when I try to create it?


The following is the code snippet in PDFViewCtrl.onScroll()

boolean handled = false;
int previous_tool_mode = mTool.getMode(), next_tool_mode;
do {
handled |= mTool.onMove(e1, e2, x_dist, y_dist);
next_tool_mode = mTool.getNextToolMode();
if (previous_tool_mode != next_tool_mode) {
mTool = mToolManager.createTool(next_tool_mode, this, mTool);
previous_tool_mode = next_tool_mode;
} else {
} while (true);
if (handled) {

As you can see, it calls ToolManager.createTool() in a loop until the previous tool mode is the same with the current tool mode. This way, you can easily chain several tools together. But of course, in order to avoid infinite loop, you will need to make sure that Tool.getNextToolMode() won’t form a loop.