Removing an event handler does not work
Original Reporter info from Mantis: yus
-
Reporter name: Yuri Serebrennikov
Original Reporter info from Mantis: yus
- Reporter name: Yuri Serebrennikov
Description:
If I describe deleting an event handler in a class, then it doesn't work.
If I describe in a procedural paradigm, then it works.
I have a code for demo.
When click left mouse in browser, i see two message
C Button = 0
P Button = 0
When i click right button event handlers should be removed, but removed only one handler.
Steps to reproduce:
program project1;
{$mode objfpc}
uses
JS, Classes, SysUtils, Web;
type
{ MyClass }
{ TMyClass }
TMyClass = class
private
function MouseDownC(aEvent: TJSMouseEvent): boolean;
public
procedure Start;
end;
function MouseDownP(aEvent: TJSMouseEvent): boolean;
begin
writeln('P Button = ', aEvent.button);
if aEvent.button = 2 then
document.removeEventListener('mousedown', @MouseDownP);
end;
{ MyClass }
function TMyClass.MouseDownC(aEvent: TJSMouseEvent): boolean;
begin
writeln('C Button = ', aEvent.button);
if aEvent.button = 2 then
document.removeEventListener('mousedown', @MouseDownC);
end;
procedure TMyClass.Start;
begin
document.addEventListener('mousedown', @MouseDownC);
end;
var
MyClass: TMyClass;
begin
// clacc implementation
MyClass := TMyClass.Create;
MyClass.Start;
// procedure implementation
document.addEventListener('mousedown', @MouseDownP);
end.
Mantis conversion info:
- Mantis ID: 38845
- Build: Release 2.0
- Fixed in revision: 49331.