# MATLAB: Simple Problem – Message Box Function

closerequestfcnmsgbox

I have no experience with GUI programing in Matlab. I've written a very simple callback function to display some text when a message box is closed. The text never shows, so I think the callback function is not being called. Can you please take a look and tell me what I'm doing wrong?
Cheers, Josh
function messageBox
    h1=msgbox('Message Display','','none','non-modal');        set(h1,'CloseRequestFcn',@closeMsg);    function closeMsg(src,eventdata)       disp('working')    end    waitfor(h1)
end

• function messageBox      h1=msgbox('Message Display','','none','non-modal');      set(h1,'Deletefcn',@closeMsg);      function closeMsg(src,eventdata)         disp('working')      endend
If you look at the code for MSGBOX, you will see that pressing the button calls DELETE, which does not use the closerequestfcn. You can see this in the doc for CLOSE (but not in the doc for DELETE?).