 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alejandro Castro Guest
|
Posted: Sat Jul 26, 2003 7:23 pm Post subject: TBasicAction ? |
|
|
I have the next problem:
I have a MainMenu with its MenuItems, every MenuItem with its onClick event.
I need to intercept the the OnClick event of every MenuItem before execute
it
I tried creating a BasicAction object and assigning the Action property of
the MenuItems, something like
FBasicAction:=TBasicAction.Create(Self);
MenuItem.Action:=FBasicAction;
now I want to assign the onExecute event of the FBasicAction
FBasicAction.onExecute := DoClick
and finally I want to code the DoClick procedure
procedure DoClick
begin
some validations;
execute the OnClick event of the MenuItem;
end;
My questions
1. Is this the way to do what I want ?
2. Why when I assign FBasicAction.onExecute:=DoClick I get an error
'Parameters lis differ'
Thanks in advance
--
Alejandro Castro
www.alfra.info
[email]alejandro (AT) alfra (DOT) info[/email]
|
|
| Back to top |
|
 |
Alejandro Castro Guest
|
Posted: Sun Jul 27, 2003 5:47 am Post subject: Re: TBasicAction ? |
|
|
Because Im writing a component and I dont want to modify my actual code
Ive tried many ways and always I get errors, my last code is like:
MenuItem.Action:=TBasicAction.Create(Self);
MenuItems.Action.OnExecute:=DoClick;
and the declaration is
property DoClick: TNotifyEvent read FDoClick write SetDoClick;
procedure SetDoClick(Value: TNotifyEvent); virtual;
FDoClick: TNotifyEvent;
and my function is like
procedure TMyClass.SetDoClick(Value: TNotifyEvent);
begin
showMessage('Im Here');
inherited Click;
end;
but now I get an "invalid class typecast" when I click on a Menu Item
Where is my error ? (Im lost !!!)
Thanks
Alejandro
| Quote: | It works, but why don't you do this at design-time with a TActionList or
TActionManager?
2. Why when I assign FBasicAction.onExecute:=DoClick I get an error
'Parameters lis differ'
Your declaration of DoClick doesn't match the declaration of the event.
.OnExecute is declared at type TNotifyEvent, and your method doesn't have
the same argument signature.
Cheers,
Ignacio
|
|
|
| Back to top |
|
 |
Alejandro Castro Guest
|
Posted: Sun Jul 27, 2003 7:46 pm Post subject: Re: TBasicAction ? |
|
|
I found the problem
Action is of the TAction type, the help file say is the TNotifyEvent type
(wrong)
"Ignacio Vazquez" <ivazquezATorioncommunications.com> escribió en el mensaje
news:3f22daa1$1 (AT) newsgroups (DOT) borland.com...
| Quote: | "Alejandro Castro" <alejandro (AT) alfra (DOT) info> wrote in message
news:3f22d652 (AT) newsgroups (DOT) borland.com...
1. Is this the way to do what I want ?
It works, but why don't you do this at design-time with a TActionList or
TActionManager?
2. Why when I assign FBasicAction.onExecute:=DoClick I get an error
'Parameters lis differ'
Your declaration of DoClick doesn't match the declaration of the event.
.OnExecute is declared at type TNotifyEvent, and your method doesn't have
the same argument signature.
Cheers,
Ignacio
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|