2

I'm implementing actions (in a TActionManager) for a user interface. Some controls, when clicked, execute the same action. However, in that action handler, I need to know which control was actually clicked by the user. But the Sender is a TAction instead of the originating control.

How can I identify which control using this action was actually pressed by the user?

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • You can find the answer here: http://stackoverflow.com/questions/5501123/which-way-that-taction-has-been-fired – Toon Krijthe Apr 06 '14 at 16:06
  • @Toon That question seems to be more about menu, button or shortcut. But I expect there's a dupe somewhere! ;-) – David Heffernan Apr 06 '14 at 16:11
  • Honestly what I'm doing is actually a menu item and a checkbox (toggling checked state back and forth at the same time) but the action execute handler is the same. – Jerry Dodge Apr 06 '14 at 16:18
  • 1
    @Jerry - for a control, you've got an answer. But note that ActionComponent will be nil when the action is executed through an action menu item, as action menu items are not components. – Sertac Akyuz Apr 06 '14 at 17:57

1 Answers1

3

You can obtain this information from the ActionComponent property of the action.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490