[Pas2js] Can't determine which overloaded function to call
warley camargo
warleyalex at yahoo.com.br
Wed Jul 1 21:44:28 CEST 2020
We can not use anonymous addEventListener method this way:
row := TJSHTMLTableElement(table).rows[i];
row.addEventListener('click', function(event: TEventListenerEvent): boolean
begin
//
end);
row.addEventListener('click', procedure(event: TJSEvent)
begin
//
end);
---> Error: Can't determine which overloaded function to call, D:\fpc2js\pas2js-windows-1.5.1\packages\rtl\web.pas(71,31),
ah, to work as expected we have to remove the overloaded method from the Web.pas unit
//--> procedure addEventListener(aname : string; aListener : JSValue); overload;
the second argument "aListener" is a JSValue, the compiler can't determine which overloaded function to call.
Web.pas unit
--------------
TEventListenerEvent = TJSEvent;
TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean; safecall;
TJSRawEventHandler = reference to Procedure(Event: TJSEvent); safecall;
TJSEventTarget = class external name 'EventTarget' (TJSObject)
public
procedure addEventListener(aname : string; aListener : TJSEventHandler); overload;
procedure addEventListener(aname : string; aListener : TJSRawEventHandler); overload;
// procedure addEventListener(aname : string; aListener : JSValue); overload;
function dispatchEvent(event : JSValue) : Boolean;
procedure removeEventListener(aname : string; aListener : TJSEventHandler);
procedure removeEventListener(aname : string; aListener : TJSRawEventHandler);
// procedure removeEventListener(aname : string; aListener : JSValue);
----------------
More information about the Pas2js
mailing list