[Lazarus] Frames and Events
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Thu Jul 14 15:39:04 CEST 2011
How can events be added to frames?
I want to add an OnFileClick event, that reacts on an click into a
listbox in the frame. The new event is typed as
TOnFileClick = procedure(Sender: TMyFrame; p,d: string) of object;
and the handler in the frame provides the strings and calls the assigned
FOnFileClick handler.
How do I make this new event appear in the Object Inspector?
Since the event is not available in the OI, I assign an handler in code.
Now I get an crash on entry of the handler. The code in the frame, which
calls the handler, is never executed. Instead the original event
(listbox1.OnClick) seems to call the user handler immediately[1], with a
wrong argument list (without the added strings) - boom :-(
The latter problem can be cured by removing and adding the frame to the
form again, but this is not a practical workaround, because then all
property settings of the frames are lost.
[1] Since I have two such frames in my form, I inspected the form.lfm
for the not removed/added frame, and find explicit Nil assignments to
the events in the frame (OnClick, OnDblClick), where the frame installs
its own handlers! Removing these entries from the lfm makes that frame
work as expected, even without removing and adding to the form again.
Should I create one or more bug reports?
DoDi
More information about the Lazarus
mailing list