Introduction
There are times when you might want an extension to have custom Work Modes tied to the extension. And have the Work Mode available when an extension is enabled, and then have it unavailable when the extension is disabled. This article guides you on how to do so.
1. Create the Work Mode File
-
Somewhere at the top left of CET, start the work mode editor (available in 5.0 develop and higher) by clicking the dropdown beside Marketplace.
-
Select any work mode, click Copy, specify a suitable name. Done. The new work mode file should be available under CET Documents/WorkModes.
2. Move the Work Mode File to the Extension Folder
Move the file from CET Documents to your extension folder, for example:
- custom/myExtension/res/WorkModes/MyWorkMode.cmwrk
The file must also need to be added into the extension as such:
files << cmNative("custom/myExtension/res/WorkModes/" # "*.*");
3. Extension Code Setup
Make a function similar to this one:
/** * Init walkthrough work mode. */ package void initWalkthroughWorkMode() { str subPath = ("custom/walkthrough/WorkModes/" # "*." # workModeFileSuffix); for (url in cmFindWildcard(subPath)) { registerWorkModeUrl(url); } }
And call it from your extension's start()
. This will make all your work modes in the specified folder show up in the work mode selection drop-down in CET.
You should also have an unregister function, like this:
/** * Unregister walkthrough work mode. */ package void unregisterWalkthroughWorkMode() { str subPath = ("custom/walkthrough/WorkModes/" # "*." # workModeFileSuffix); for (url in cmFindWildcard(subPath)) unregisterWorkModeUrl(url); }
Call it from your extension's stop()
.
4. Fine Tune the Work Mode
After restarting CET, your work mode should show up as a predefined (blue) work mode in the work mode editor. In develop mode you are able to edit even predefined work modes by pressing the orange Unlock button. (If this button is not visible, go to cm/core/workModeEditor.cm and set the officialMode
bool to false). After editing the work mode, CET Operator should notice the changes and open the file for edit so that you may submit your changes.
Full working example code is available in base/custom/walkthrough/
Comments
0 comments
Please sign in to leave a comment.