I've created a 2D Drafting Addin with ribbon in C# from Jason's templates. I currently have a button that when clicked, looks at the select set and for each item in it, if it is a dimension, it applies a custom format to that dimension.
Although this works fine, I would like to be able to 'activate' the command by clicking the button and have it highlighted or something, then click dimensions in the view to format them. Then deactivate the command by Esc or right click. I.e. I'd like it to work more like the built in SE commands.
I don't necessarily want exact code, but what's the workflow to achieve this?
Solved! Go to Solution.
for your purpose exist the Command object and its Mouse property. The workflow would be as follows:
On click of your button you create an instance of the Command object and assign its Mouse property to a corresponding Mouse object. Now you configure your Command and Mouse objects. I.e. assign an event handler method for the mouse click event. In the mouse click event you will be able to locate the clicked object and in case of a dimension object perform your formatting. With the Start() method of your command instance you start the command and it behaves like a built in command.
Keyboard events (like detecting the press of the ESC key) can be handled by your program as usual. In the corresponding event handler for a key press of the ESC key you can terminate your started command instance by setting its property Done to true.
Jason has provided good examples of how to use the Command and Mouse objects in his examples downloadable on github.