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

5 次查看(过去 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 中查找有关 Install Products 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by