Added code for custom button

Please delete this pull request. I've refined my approach and will add another pull request later.