From: Raphael J on
Hello,
I have a little problem with "waitforbuttonpress". Why does it not accept a button press over a button? This seems not logical to me. The execution is blocked until I click beside the pushbutton directly the figure.

Thanks for any help.

Here a test script to visualize my problem:

figure('units','normalized','position',[0.05 0.1 0.4 0.4], 'name', ...
'waitforbuttonpress_test ','NumberTitle','off',...
'color',[0.35 0.35 0.35],'doublebuffer','on','backingstore','off',...
'menubar','none', 'tag','figure_of_test');

playvals.playbutton = uicontrol('style','pushbutton','string','Play',...
'units', 'normalized', 'position', [0.1 0.215 0.8 0.1],...
'foregroundcolor',[0 0.7 0],...
'fontunits', 'normalized', 'fontsize', 0.6,'tag', 'playbutton');

text1 = 'Please press button';
text2 = 'Thanks';

playvals.text1 = uicontrol('style','text','string',text1,...
'units', 'normalized', 'position', [0.1 0.615 0.8 0.1],...
'fontunits', 'normalized', 'fontsize', 0.6,'tag', 'text1');

waitforbuttonpress

playvals.text2 = uicontrol('style','text','string',text2,...
'units', 'normalized', 'position', [0.1 0.5 0.8 0.1],...
'fontunits', 'normalized', 'fontsize', 0.6,'tag', 'text2');

From: Jan Simon on
Dear Raphael!

> I have a little problem with "waitforbuttonpress". Why does it not accept a button press over a button? This seems not logical to me. The execution is blocked until I click beside the pushbutton directly the figure.

In the help text of WAITFORBUTTONPRESS you find:
"Wait for key/buttonpress over figure".
If the pointer is over a *button*, the figure is concealed by this object and the event is caught by the button's callback function.
If you want to ignore the button's callback, you can set its 'Enable' property to 'inactive'.

Good luck, Jan
From: Raphael J on
Hi Jan,
thanks a lot!
I just added 'Enable','inactive' to the pushbutton properties!