I have a client who is using my plugins on both Mac (Mojave) and Windows. He is running SU 2018 Pro.
When he toggles the plugin toolbars off on the Mac they don’t retain that status on a restart of SketchUp and reappear. On Windows they behave as expected.
However, if they are re-positioned on the Mac they do retain their new position after restart.
Has anyone else experienced this behavior on a Mac running SU 2018 or 2019? Resolution?
After digging through various threads on this board and others it appears I am not the first to encounter this problem.
My question now is how do I fix it? I’m not finding a solid resolution on any other threads. If I have something wrong in my code I am more than happy to correct it.
Here is an example of a chunk of the code which creates part of a toolbar:
I’ve been using this same code since Oct. 2015 (beginning of the truss plugin).
So I’ve had it wrong for years now… wow.
The funny thing is that in windows it remembers the last state and does not show the toolbars if they were turned off, even with the code I am using now. I guess my understanding of the API is flawed.
The documentation does not give good examples, I wouldn’t take them as standard methods. Many examples date back to the beginning when the API was designed and the developers where yet deeply familiar with conventions in the Ruby community (and people like me didn’t even start programming at all at that time).
inconsistent variable naming (camelCase)
UI.messagebox in a long loop instead of puts
unnecessary boolean checks for method return values that practically always succeed
examples that return a new instance of an object without showing what the result looks like or what can be done with it
In the stubs repo we (community developers) started to introduce corrections and some better examples, but the API is extensive, we don’t know whether Trimble employees invest efforts in parallel and before starting one would first need to define goals and guidelines for creating uniform, consistent examples.
I appreciate the further clarification. I always assumed that the examples provided in the documentation were “best practice” examples and just took it as gospel. Granted I have come up with my own methods and means but I’m a little disappointed (and even shocked) that the documentation is not more carefully vetted and updated as the need requires.
It depends on the situation. A user who has just installed an extension should know where to find it.
If the toolbar is the main way to invoke the extension it is best practice to show the toolbar on first start.
If the extension is rarely used or has another obvious way to invoke it, but I want to provide an optional toolbar so that people who prefer toolbars can enable it manually in the menu, I just register it without making it pop up (restore without show).
To be fair the method shown above for creating a toolbar is okay, it just doesn’t show you the proper method for initiating your toolbars so that they retain or restore their previous settings. I will take things with a bit of a grain of salt from here on out.