LibActionButton-1.0 is a library that provides a button template which can work with actions, spells, items, macros, and anything else you could put on a secure button.
This library exposes a simple interface to create new buttons, and will shield you from all the restricted environment magic needed to implement a truely generic action button.