How to have UI "Abort" a clear button

I have a change to make to the UI… New Rule for Closing and Clearing the screen

  • When the user presses the Close button, or the CLEAR tool, Check to see a certain condition, and if found, abort the clear operation.

I have figured out how to capture the clear tool… BUT, I have not figured out a “clean” way to stop the clear function.
Currently, I have the following… the CLOSING version works… because it has a “Cancel” option… but the toolclick doesn’t seem to work the same way.
I did try to reset the args.Tool.Key value… this “Works” in that it stops the clear function, but, it also throws an error that I am not allowed to change args.Tool.Key… Ideas?

Below is some pseudocode (took out extended details of “condition”).

	private void SalesOrderForm_Closing(object sender, System.ComponentModel.CancelEventArgs args)
	{
		// Add Event Handler Code
		if (some condition){
                    //throw error here
                    args.Cancel = true;
        }
	}


	private void SalesOrderForm_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
	{
		if(args.Tool.Key == "ClearTool"){
		if (some condition){
                     //throw error here
                     args.Tool.Key = "";
        }
	}
'''

Can you try
args.Handled =true
In before toolclikc?

2 Likes

That did the trick! exactly what I wanted.