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

1 view (last 30 days)
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 Comments
George Baltas
George Baltas on 18 Dec 2018
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 on 18 Dec 2018
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

Sign in to comment.

Accepted Answer

George Baltas
George Baltas on 2 Jan 2019
This bug got fixed in 2018b

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!