Forum > General

Events triggered twice

(1/2) > >>

jolix:
Hi,
Some one else experience the same behavior i get with some Edit/Combo events, that are triggered two times?
Simple example:

--- Code: ---unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
      Edit1: TEdit;
      procedure Edit1EditingDone(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.Edit1EditingDone(Sender: TObject);
begin
    Edit1.OnEditingDone:=nil;  // Disable to avoid MessageBox apear two times
    ShowMessage('EditingDone Event!');
    Edit1.OnEditingDone:=@Edit1EditingDone; //Reenable event
end;

initialization
  {$I unit1.lrs}

end.

--- End code ---
This only happens with Edit.OnEditingDone and to avoid event repeating, i have to disable event and turn it again, as can see on the example above.
Message 'EditingDone Event!' apears two times when i press Enter Key.
While editing, if i use OnClick or OnDoubleClick instead, event is triggered just one time as supposed to.

What i'm doing wrong?

The behavior is the same with all Lazarus versions since 0.9.26 until 0.9.29, WinXP / Vista.

Thanks
jolix

zeljko:
Report an issue about it.

jolix:

--- Quote ---Report an issue about it.
--- End quote ---

Thanks zeljko.
This is really anoying.
jolix

mas steindorff:
you may be able to set a breakpoint and look at the call stack each time.  you may see a second call back that can be disabled.

If it's real, what I would do is to start a short timer (say count of 30 or so) and put the real code (and timer disable) in it's Ontimer.  then you can check to see if you have already enabled the timer on the second pass

ivan17:
i only get the message shown once (w32 widgetset).

however, sometimes (depending on how i ended the editing) the focus doesn't move where i told it to.

Navigation

[0] Message Index

[#] Next page

Go to full version