Instead of creating these buttons yourself, change the top-level element from *<window>* to *<dialog>*, which will automagically create nativeish accept/cancel buttons for you using the [dialog XBL binding](http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/dialog.xml), which dispatches *dialogaccept* and *cancel* events when the user presses the buttons. See the [print page setup dialog](http://mxr.mozilla.org/mozilla-central/source/toolkit/components/printing/content/printPageSetup.xul), for an example, noting especially its *<dialog>* element's *ondialogaccept* and *oncancel* attributes.