title: Dart how to determine the source of an on click event
body: <p>I have some radio buttons; some action takes place when a button is clicked.  How can I implement code that simulates a click event and detect if the 'click' was caused by the simulation or the user? </p>
  
  <pre><code>chkBxB12 = querySelector('#B12');
  chkBxB12.onClick.listen(chkBxB12Clicked);
  
  void chkBxB12Clicked(Event e) {
    // do something
    // if mouse click or tap then
    //   do some-additional-thing 
  }
  
  foo() {
      chkBxB12.click()
  {
  </code></pre>
  
  <p>[edit] </p>
  
  <p>I modified JAre's example to better suit my needs (and reduce 8 methods to handle my four radio buttons to two - Robert's example reminded me of that need).  Here's the modified code that allows determination if a target button is clicked (or tapped) by hardware of software and the identity of the button.</p>
  
  <pre><code>import 'dart:html';
  
  void main() {
    querySelectorAll('input[type="radio"]').onClick.listen(foo);
    foo(new MouseEvent("synthetic")); // parameter is
  }
  
  
  
  void foo(MouseEvent event) {
    if (event.target is Element){
      Element target = event.target;
      if(target.id == 'radio1')
        print('${event.type} target ${target.id}');
      else if(target.id == 'radio2')
        print('${event.type} target ${target.id}');
    }
    else {
      if(event.type == "synthetic") print(event.type);
      else print("It didn't work!");
    }
  }
  </code></pre>
  
  <p>Output is as expected:</p>
  
  <pre><code>synthetic
  click target radio1
  click target radio2
  </code></pre>