Board index » cppbuilder » Finding initiator of TAction

Finding initiator of TAction


2007-07-31 09:31:31 PM
cppbuilder110
Hello,
we use a TActionList with TAction objects to centralize
funcionality.
For each TAction object the OnExecute handler is implemented.
Each action is normally assigned to several VCL objects like TButton, TMenuItem etc. This works fine.
Now, one special action needs to be assigned to two different buttons with a slightly different meaning. So, in the OnExecute handler, we want to know which button was pressed. Normally, I would cast the Sender parameter, but in the OnExecute handlers, the sender is the TAction object, not the pressed button.
Is there a way to find the actual initiator of the action? I looked at the properties and methods of TAction but didn't find any hint.
Otherwise we have to store the info about the pressed button in a global variable.
Thanks,
Thomas
 
 

Re:Finding initiator of TAction

Sorry for not inserting line feeds in the posting :-(
 

Re:Finding initiator of TAction

Hi Thomas,
You can cast the Sender to a TAction, and then use the
TAction::ActionComponent property to determine which component initiated
the action.
Cheers,
Thomas Blankschein wrote:
Quote
Is there a way to find the actual initiator of the
action? I looked at the properties and methods of
TAction but didn't find any hint.
 

{smallsort}

Re:Finding initiator of TAction

Hello,
Quote
You can cast the Sender to a TAction, and then use the
TAction::ActionComponent property to determine which
component initiated the action.
Thanks for the info. Unfortunately I use BCB5 where TAction
doesn't seem to have this property. I should have mentioned my
BCB version before, sorry.
Thomas
 

Re:Finding initiator of TAction

"Thomas Blankschein" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks for the info. Unfortunately I use BCB5 where
TAction doesn't seem to have this property. I should
have mentioned my BCB version before, sorry.
Then there is no way for you to determine the initiating component from a
TAction pointer. That functionality was introduced in BCB 6.
Gambit
 

Re:Finding initiator of TAction

Thanks Gambit for the information. This is not mission critial
for us.
Thomas