In the previous article, we talked about how to create a comprehensive TaskDialog through using every single property and method that the Revit API provides. In this post, let’s see how to create some TaskDialog instances with some shortcut public static methods that the TaskDialog class has.
The first one has only two arguments, title and main instruction:
TaskDialog.Show("This is 'title'.", "This is 'mainInstruction'");
If the above code is wrapped into an external command and in turn triggered by a ribbon item, e.g. a PushButton, a TaskDialog like the following will appear:
As can be seen besides the title and the main instruction that are specified explicitly in the code, a default Close button will also be there and the TitleAutoPrefix property of the TaskDialog is set as true by default, therefore, the button name will show up as the prefix to the title.
Can we do something about it? No, not at all since the TitleAutoPrefix property is instance applicable instead of static. So if this is not wanted, a TaskDialog instance has to be created explicitly, obviously.
The second shortcut provides one more argument, common button options:
TaskDialog.Show("This is 'title'.", "This is 'mainInstruction'", TaskDialogCommonButtons.Cancel | TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Close |
TaskDialogCommonButtons.No | TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.Retry |
TaskDialogCommonButtons.None);
If the above code is wrapped into an external command and in turn triggered by a ribbon item, e.g. a PushButton, a TaskDialog like the following will appear:
This time, the Close button is replaced by the common buttons that are specified in the third argument and the first button is highlighted as default.
The third shortcut method provides one more argument, the default common button:
TaskDialog.Show("This is 'title'.", "This is 'mainInstruction'", TaskDialogCommonButtons.Cancel | TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Close |
TaskDialogCommonButtons.No | TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.Retry |
TaskDialogCommonButtons.None, TaskDialogResult.Cancel);
If the above code is wrapped into an external command and in turn triggered by a ribbon item, e.g. a PushButton, a TaskDialog like the following will appear:
As can be seen, the Cancel button is highlighted this time as the default button meaning when the Enter key is pressed the button will be equally clicked and in turn the TaskDialog closed.
That is it for today. TaskDialoger of RevitAddinWizard can help create the code automatically.
Recent Comments