SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
38 stars 10 forks source link

Tool#getInstructorContentDirectory called constantly on Mac OSX #475

Open Fredosixx opened 4 years ago

Fredosixx commented 4 years ago

On Mac OSX, the callback method getInstructorContentDirectory is constantly called when the instructor is opened (before or after launching the Tool)

On Windows, it is called once per Tool session.

The Windows behavior makes more sense, because the callback is just supposed to provide the directory for the instructor index.html file.

Anyway, this is a different behavior on Mac OSX and Windows.

DanRathbun commented 4 years ago

I agree. Also it'd would make sense if this callback was called once during construction of the tool object.

Why (rhetorically) would we suppose that the content directory would be changing during a session ? We would not. It likely will not ever change location after installation of an extension (implementing a tool.)

Fredosixx commented 4 years ago

On Windows, the method is called only ONCE, but at the moment you open the Instructor (or at activation of the tool, if the Instructor is opened).

On Mac, it is called constantly whenever the instructor window is visible.

Note that in the case of FredoSpline, I use the same Tool class for 5 different modes. So I build the HTML dynamically for each mode the first time the tool get called by getInstructorContentDirectory.

Fredosixx commented 4 years ago

Actually, I realized that getInstructorContentDirectory is also called whenever you do a UI.refresh_toolbars. It is also called when the cursor enters the Inspector window.

I was making tests with a periodic timer on UI.refresh_toolbars and that's why I was getting constant calls to getInstructorContentDirectory.

So the situation is not that worse, but it would be clearer that things are either documented or fixed to have a similar behavior between Windows and Mac OSX.

Eneroth3 commented 4 years ago

This could be called once during the construction and cached, but it's probably simpler to call it whenever the tool is either activated or resumed, which is when the instructor should change and the value is needed by SketchUp.

thomthom commented 4 years ago

Actually, I realized that getInstructorContentDirectory is also called whenever you do a UI.refresh_toolbars. It is also called when the cursor enters the Inspector window.

Hm... good find. I would not expect that.

sketchupbot commented 4 years ago

SU-46195