Is there any problem?
Is this with a simple Alert (only answerable with "OK"), with a Confirm (one of "Yes" or "No"), or a Prompt (enter text, then "OK", or "Cancel") dialog?
You don't need to apply a function to the buttons in the title bar. Tell your users to click one of the provided text buttons. They're there for a reason.