필터 지우기
필터 지우기

waitforbuttonpress & 'windowbuttondownfcn' callback for mouse clicks

조회 수: 1 (최근 30일)
inci
inci 2012년 4월 30일
Hi,
I am building a GUI where I define flags for mouse clicks (i.e:
set(gcf, 'windowbuttondownfcn',mousedown=1;')
and buttons for a certain selection of a variable (i.e.
uicontrol('style','pushbutton',....'variable=1;'
I try to use waitforbuttonpress & 'windowbuttondownfcn' callbacks together so that the programme waits for the subject to press a button for the variable selection. When I use "pause", everything seems to work smoothly. With the "waitforbuttonpress", however, it does not save the variable selection. In other words, it skips the callback function. Preferably, I'd like all the response collection to be through mouse clicks so I would be happy if you could give me some other ideas how I can achieve my goal: Problem is:
variable = 0;
set(gcf,'windowbuttondownfcn','mousedown=1;');
uicontrol('style','pushbutton',...,'callback','variable=1');
p=waitforbuttonpress %(Let's say I press the uicontrol for variable=1)
variable
on the command window variable = 0

답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 4월 30일
I would guess the callback is operating but the variables are deleted at the end of the callback. This is typical. When a function ends, everything inside of it is cleared and not accessible.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by