Webassembly event handling

I am struggling to use/understand event handling in webassembly.
How can I create an event handler (eg for a button onclick) that will pass the button evement to the event handler?

For example the following works:

  var btn := WebAssembly.GetElementById('myButton');
  btn.onclick := new WebAssemblyDelegate((a) -> ButtonClick(a));
  writeLn('button inst id: ' + btn.id);
end;

But this gives the compiler error “no such member” for e.id:

method ButtonClick(e: EcmaScriptObject);
begin
  writeLn('button click id: ' + e.id);

end;

Thanks
Ian

You’ll want to define “e” as dynamic, that way you can access any json member on it.

I tried that and that stops the compiler error but e.id does not return anything.

I tried the following but it also does not return anything:

method ButtonClick(e: dynamic);
begin
  for s in e.GetNames do
    writeLn(s);