COPA-DATA Add-In: Capturing the Button That Invokes It

Karen Mitchell1 min read
HMI ProgrammingOther ManufacturerTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Use the element mouse event as the execution context

A generic COPA-DATA Add-In cannot reliably identify its invoking button from the linked function alone based on the available evidence. Instead, handle the screen element's left-button event. The documented approach identified in the evidence combines WithElementLeftButtonDownEventArgs with IControlElement, allowing the Add-In to inspect the control element associated with the click.

Select the supported event path

Requirement Evidence-supported choice Status
Identify the clicked button Handle the element left-button-down event Supported
Represent the clicked control Use IControlElement Supported
Handle left-button-up instead ElementLeftButtonUpEventArgs is mentioned only as a requested example Implementation not established
Read a parent object Start from the event-associated control element and inspect exposed properties Exact parent member not established

Capture and process the clicked control

  1. Register the Add-In for the screen element's left-button-down event using the API mechanism associated with WithElementLeftButtonDownEventArgs.
  2. When the event fires, obtain the associated IControlElement from the event context.
  3. Read the properties exposed by that control element and use them to select the generic Add-In behavior.
  4. Before depending on a parent relationship, verify that the API exposes the required parent property for the returned control element; the evidence does not establish a specific member name.

Verify the event-to-element mapping

Place multiple buttons on the same screen and invoke the Add-In from each one. Confirm that every click supplies the corresponding IControlElement and that the inspected properties change with the selected button. Separately test any left-button-up implementation because the available evidence confirms only the left-button-down approach.

FAQ

How can a COPA-DATA Add-In identify which button was clicked?

Handle the element left-button-down event with WithElementLeftButtonDownEventArgs and obtain the associated IControlElement. Read that element's exposed properties to determine which button invoked the logic.

Can I get the clicked button's parent from IControlElement?

The evidence supports accessing the clicked control through IControlElement, but it does not confirm a specific parent property. Inspect the API members exposed by the returned element before designing logic around a parent reference.

How do I implement ElementLeftButtonUpEventArgs?

The available evidence requests an example but does not provide or confirm an implementation. Use the supported left-button-down event path unless the applicable Add-In API documentation confirms the required button-up event and its element-access mechanism.

Back to blog