How to add two functions as Callback in uicontrol

8 ビュー (過去 30 日間)
Jasmine Shragai
Jasmine Shragai 2015 年 8 月 1 日
編集済み: Alexander Schukmann 2019 年 1 月 16 日
Hi everyone,
I have a figure opened with two push buttons. While clicking each of the buttons, the value of a certain variable changes.
I would like to make it so the figure also closes once one of the buttons is pressed.
I have tried many variations in order to do this but none work, since I am trying to add 2 functions to the same call back. I know I can create an external function to do this, but it seems redundant.
Is there a simple way to apply this?
Thank you so much!

採用された回答

Jasmine Shragai
Jasmine Shragai 2015 年 8 月 1 日
編集済み: Jasmine Shragai 2015 年 8 月 1 日
Hello Walter, Thanks for the reply!
Actually I'm not using GUIDE. Here is an example for the part I'm working on:
lang_eng = uicontrol('style', 'pushbutton',...
'fontsize', 12,...
'string', 'English',...
'units','normalized',...
'position', [0.55 0.5 0.2 0.1],...
'callback', 'lang = eng', 'callback', 'close all');
Obviously it doesn't work that way :)
  3 件のコメント
Jasmine Shragai
Jasmine Shragai 2015 年 8 月 2 日
Genius! Thank you so much :)
Alexander Schukmann
Alexander Schukmann 2019 年 1 月 16 日
編集済み: Alexander Schukmann 2019 年 1 月 16 日
Thank you!
Is there any way to have two callbacks in the form
uicontrol('Callback',@myfunction);
uicontrol('Callback','uiresume(gcbf)');
included in the same "uicontrol"?
Many thanks!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 8 月 1 日
It sounds as if you might be using GUIDE. If so use the Property Inspector to edit the Callback property, which will be a string. You can edit the string to close() the figure handle.
Caution: there is a possibility that the Callback might get changed back by GUIDE.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by