How exactly the 'Enable' property works for GUI elements (ans is it bugged??)

조회 수: 1 (최근 30일)
I experienced the following behavior. Created a push button (we talk about uifigure) set its 'Enable'='off' attached a 'ButtonPushedFcn' to it.
So far so good, then i proceed to play around with my UI the button is disabled and grayed out, I click on it and nothing happens (as it should)
Then I proceed to click it again multiple times in quick succession, nothing happens (again as it should) then suddenly my callback function is called!!!!!!!!
I can reproduce this behavior and it is really confuses me, please let me know if you have any advice on the matter.
For refference:
matlab.ui.control.Button('Parent', myHandle , 'BackgroundColor', myBackground,...
'Position', myPosition ,'Enable','off', 'Text', myText,...
'HorizontalAlignment', 'center','FontName', 'arial','FontWeight', 'bold','FontSize', 11,...
'ButtonPushedFcn', @(src,event) myCallbackFcn(app,src,event,index));
function myCallbackFcn(app,src,event,index)
%%%%
end
  댓글 수: 4
George Baltas
George Baltas 2018년 12월 18일
classdef test
properties
myFigure
end
methods
function app=test
app.myFigure=uifigure;
matlab.ui.control.Button('Parent',app.myFigure,'Enable','off','ButtonPushedFcn', @(src,event) myCallbackFcn(app,src,event));
end
end
end
function myCallbackFcn(app,src,event)
disp('hello world')
end
George Baltas
George Baltas 2018년 12월 18일
I am using 2018a
Run the above as is, I click at the edge of the grayed out Button and I can call the callback function. I click at the body of the button and nothing happens. Is this how it is supposed to be or I am missing something. Thank you in advance.matlab problem.PNG

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

채택된 답변

George Baltas
George Baltas 2019년 1월 2일
This bug got fixed in 2018b

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by