Hi all,
I have a quick question I am working on an automation script and have run into an issue. I have created a dialog button and I am trying to run a method when the butto is pressed. so far I have this:
public event EventHandler<EventArgs> Pressed;
public void Button_Pressed(object sender, EventArgs e)
{
controller.Engine.Log("Entering Event");
AddPort(sender, e, protocol.Protocol);
controller.Engine.ExitSuccess("0");
}
I have tried both of these but the method does not trigger when button is pressed
dialog.Button.Pressed += new EventHandler<EventArgs>(Button_Pressed);
dialog.Button.Pressed += (sender,e) => Pressed(sender,e);
I have a drop down list and everything works for the OnChange event but for the button I can't get it to work.
Thank you so much in advance.
Hi Amer,
I assume the button is a property of your dialog class.
Check that the button property does not get overwritten after subscribing to the Pressed event.
In case you are running a very old version of the toolkit, make sure the WantsOnChange property of the button is set to True.
This is not needed on recent versions, and you might not be able to access the property, ignore this if that is the case.
The 2 examples you gave to subscribe seem to be valid.
But I would write it like this:
dialog.Button.Pressed += Button_Pressed;
If nothing worked, would it be possible to share more of the code in the dialog class?
Would it be possible to share the code via github gist?
Yes the button is a property of the dialog class and I am using the newest toolset so OnChange should be set to true when subscribed to the event as it is with the dropdown event.
Button = new Button(“Update Name”);
public Button Button { get; set; }
if any more info is needed to help with this let me know.
I wrote it as you have there and still the same the client waits for user input I press the button and nothing happens but in the logs it detects the button was pressed but does not trigger the method at all as I am logging when it enters the method