Welcome to the board!
I don't think you can get a button to do anythingwhile the cursor is in a cell. You have to press enter, or escape, or click somewhere, or do *something* to exit the cell BEFORE clicking the button. In the scenario you described, the *something* is clicking outside of the cell (on the button).