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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
George Baltas
George Baltas il 18 Dic 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 il 18 Dic 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

Accedi per commentare.

Risposta accettata

George Baltas
George Baltas il 2 Gen 2019
This bug got fixed in 2018b

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by