WindowButtonMotionFCN callback slow down the application

조회 수: 11 (최근 30일)
Oliver Nann
Oliver Nann 2018년 11월 30일
댓글: Cyrano Chatziantoniou 2023년 2월 21일
I have a GUI with several objects ( axes, tables, checkboxes, labels ...), when i move over the axes i read the mousposition with the WindowButtonMotionFCN callback to show the data continously. The WindowButtonMotionFCN is only available for the whole figure so the callback is permantly firing when i move the mouse in the application. My problem now is when i move the mouse over the table or when i pushed a button, than it is so slow, sometimes over 10 seconds with no response. I checked the lag with the profiler and found out that the lag is from the WindowButtonMotionFCN because the event is permantly fired and caused a queue of WindowButtonMotionFCN. I tried to perpare the interrupte-properties, but it changed nothing.
Is there a opportunity to give a callback only for a object and not for the whole figure?
Has someone similar expericence or can give me a idea how to solve the problem?
Thanks in advance.
  댓글 수: 3
Cyrano Chatziantoniou
Cyrano Chatziantoniou 2023년 2월 21일
I just updated matlab from 2021a to 2022b. That fixed my problem. If it ever returns, I'll try this solution!

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2023년 2월 21일
function WindowButtonMotionFCN(FigH, EventData)
persistent blockCalls % Reject calling this function again until it is finished
if any(blockCalls), return, end
blockCalls = true;
moved = true;
while moved % Repeat until the motionhas stopped
pos = get(FigH, 'CurrentPoint');
... Your code here
moved = ~isequal(pos, get(FigH, 'CurrentPoint'));
end
blockCalls = false; % Allow further calls again
end

카테고리

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