I have found a simple solution to this problem which came to me when I was writing the last post.
The solution is to create a blank pde file which is stored in the data folder of the Tool, then it is a simple matter of using the addFile() method in Sketch to add this as a new Tab.
How to do thisUsing the Tools Template I created a project in Eclipse.(in Windows 7), although it creates a
data folder under the main project heading this does not appear to be included in the build, so create a new folder called
data inside the
src folder. In this
data folder create a blank or template pde file. I have called this test.pde
In the Tools run() method the followwing 2 lines will copy the file to the sketch and add it as a new Tab
- String s = editor.getBase().getSketchbookFolder().toString() + "\\tools\\##name##\\src\\data\\test.pde";
- editor.getSketch().addFile(new File(s));
Obviously this is just the starting point the code would need to check if the tab already exists etc. but it works also the file does not have to be blank it could be like a template for something.
@fjenett just spotted your post I had thought of that but I must admit I quite like my solution. Thanks
