Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Clicking Disabled Button Generates Error

Asked by Jeff on 8 Nov 2011

Hi all,

I've designed an audio experiment where a sound is presented and subjects then have to respond using a touchscreen by pressing one of three buttons. I've made it so that once a sound is played, buttons are then enabled, and once they are pressed, they are disabled. When I press the first button twice, even though it is disabled after the first press, I get the following error:

??? Error using ==> feval
Undefined function or method 'pushbutton1_ButtonDownFcn' for input
arguments of type 'struct'.
Error in ==> gui_mainfcn at 96
Error in ==> run_timbre_exp at 42
    gui_mainfcn(gui_State, varargin{:});
Error in ==>
??? Error using ==> pause
Error while evaluating uicontrol ButtonDownFcn

The weird part is that I get this error for only ONE of the buttons. Any ideas as to what is going on?


Naz on 8 Nov 2011

I always use pushbutton_Callback and int works good for me (it is not necessary to use buttonDown).

Naz on 8 Nov 2011

??? Error using ==> pause

Jeff on 8 Dec 2011

I'd like to revive this thread because I still haven't solved this issue. I tried using a try/catch block to suppress the error, but this error isn't even picked up by the try/catch block.




No products are associated with this question.

2 Answers

Answer by Walter Roberson on 8 Dec 2011
Accepted answer

Have you defined both a Callback and a ButtonDownFcn for the button? If so then when you click the first time and set the enable state to disable, you are doing that with the Callback, but with the button set to disabled, it is the ButtonDownFcn that has control (unless HitTest is set off). And you have somehow set a ButtonDownFcn property for the control but have removed the corresponding routine. So go in with the property inspector, clear the ButtonDownFcn for pushbutton1 and re-save.

1 Comment

Jeff on 8 Dec 2011

I didn't think I had defined both a Callback and a ButtonDownFcn, because there was no code for ButtonDownFcn in the Editor, but in the property inspector ButtonDownFcn was defined as predicted by Walter Roberson. Thanks so much for your suggestion, Walter.

Walter Roberson
Answer by Malcolm Lidierth on 8 Dec 2011

pause causes the event despatch thread to be flushed. It looks then, as though the second button click event is despatched before the button is disabled and is on the EDT. Have you tried defining a nop 'pushbutton1_ButtonDownFcn'


Malcolm Lidierth

Contact us