[Lazarus] Menu Click Event in Runtime

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Menu Click Event in Runtime

Rogério Martins
Hi !

How do i make an assignment between a TMenuItem.OnClick event and the procedure xyz (Sender: TObject)  at runtime ?

In Delphi i just do:

menuItem.OnClick := MenuClick;
where procedure declaration is procedure MenuClick(Sender: TObject);

In lazarus, this code does not compile.

How do i correct this ?
Thanks
--


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Menu Click Event in Runtime

Marcos Douglas
2011/4/29 Rogério Martins <[hidden email]>:

> Hi !
>
> How do i make an assignment between a TMenuItem.OnClick event and the
> procedure xyz (Sender: TObject)  at runtime ?
>
> In Delphi i just do:
>
> menuItem.OnClick := MenuClick;
> where procedure declaration is procedure MenuClick(Sender: TObject);
>
> In lazarus, this code does not compile.
>
> How do i correct this ?

Use:
menuItem.OnClick := @MenuClick;

Marcos Douglas

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Menu Click Event in Runtime

Rogério Martins
It worked

Thanks!

2011/4/29 Marcos Douglas <[hidden email]>
2011/4/29 Rogério Martins <[hidden email]>:
> Hi !
>
> How do i make an assignment between a TMenuItem.OnClick event and the
> procedure xyz (Sender: TObject)  at runtime ?
>
> In Delphi i just do:
>
> menuItem.OnClick := MenuClick;
> where procedure declaration is procedure MenuClick(Sender: TObject);
>
> In lazarus, this code does not compile.
>
> How do i correct this ?

Use:
menuItem.OnClick := @MenuClick;

Marcos Douglas

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Menu Click Event in Runtime

leledumbo
Administrator
In reply to this post by Marcos Douglas
> Use:
> menuItem.OnClick := @MenuClick;

Or compile in Delphi compatibility mode