フィルターのクリア

pushbutton uicontrol blinkiing (for click me attention seeking)

11 ビュー (過去 30 日間)
venkat ta
venkat ta 2019 年 10 月 22 日
編集済み: Adam Danz 2021 年 6 月 12 日
Hi,
I am looking the set function for clicking the pushbutton with some highlights , its for special attention.
That would be really appriciated if some body send the idea.
Thanks
Best regards
Venkat

回答 (1 件)

Adam Danz
Adam Danz 2019 年 10 月 22 日
編集済み: Adam Danz 2021 年 6 月 12 日
Here's a functional demo you can apply to your GUI (whether it's built from Guide, uicontrol, or App Designer). Save it to an m file and run it.
It creates a timer that iteratively turns on/off the visibility of a graphics object. You could change the background color or any other property instead. When the timer is stopped, the stopFcn ensures that the botton is returned to its original state.
See in-line comments for more detail.
% Create a figure that contains a button.
% In this demo, the button does nothing.
figure()
bh = uicontrol('style','PushButton','String','press me');
% Create timer class
% This can be created in the startup function where you have access
% to the button's object handle.
t = timer();
t.TimerFcn = {@flashButtonTimer, bh}; % This function responds to start(t)
t.StopFcn = {@stopButtonFlash, bh}; % This function responds to stop(t)
t.Period = 0.25; % delay between flashes (seconds)
t.ExecutionMode = 'fixedSpacing';
TasksToExecute = 3;
% Define function that controlls the button flashes after start(t) is executed
% This can go anywhere in your GUI code.
function flashButtonTimer(~, ~, objHand)
% objHand is the handle to the button that should flash
% Toggle the visibility of the object. Note, you coud do lots of other things
% instead such as changing the background color of the object.
if strcmpi(objHand.Visible,'on')
objHand.Visible = 'off';
else
objHand.Visible = 'on';
end
end
% Define the stop function that ensures the button visibility is on at the end.
% This can also go anywhere in your GUI code.
function stopButtonFlash(~,~,objHand)
objHand.Visible = 'on';
end
To start flashing the button, use start(t) and to stop, stop(t). These should be called from within your GUI and the callback function must have access to 't', the timer.
When you close the gui, you should delete the timer using delete(t).
  2 件のコメント
SUMAN DUTTA
SUMAN DUTTA 2021 年 6 月 12 日
How to highlight a pushbutton already coded in a gui by changing it's colour i.e. making it blink by different colours in the middle of the execution of the program.
Adam Danz
Adam Danz 2021 年 6 月 12 日
You can adapt the example in my answer or this example using a lamp to apply it to your button. You can change the BackgroundColor property, for example.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by