フィルターのクリア

Same button in several GUIs?

1 回表示 (過去 30 日間)
Andreas
Andreas 2014 年 11 月 21 日
回答済み: Adam 2014 年 11 月 24 日
Hello together, I programmed a GUI with GUI Layout Toolbox with several TabPabels, CardPanels etc. My question is how can I create one single button and embed this button several times on different TabPanels, CardPanels, maybe also on a SubGUI. This button calls always the same callback function Is this possible somehow?
[EDITED, moved from Answer section]
Maybe a button is a bad example instead thinking of an editable text field in several TabPanels. Each field can call the same callback function. That's a good way. But when entering a text into a field all other fields in the GUI should have the same content when going to the other TabPanels. I would have to take care about that for each field. It would be easier when only one text field exists which is implemented several times. Is there a way?
  2 件のコメント
Doug Hull
Doug Hull 2014 年 11 月 21 日
How is it "the same button"? It could be a button that does the same thing with same properties?
Jan
Jan 2014 年 11 月 24 日
After [EDITED]: This is still a contradiction: "one field exists" and "which is implemented several times".
Why not creating several fields and update them in the callback?

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

回答 (2 件)

Jan
Jan 2014 年 11 月 22 日
You can create different buttons, which all call the same callback function. This should be sufficient.

Adam
Adam 2014 年 11 月 24 日
You can use the linkprop function to achieve this as well as callbacks if you want.
hFig1 = figure;
hText1 = uicontrol( hFig1, 'Style', 'text', 'Position', [10 10 125 25], 'String', 'Some text' );
hFig2 = figure;
hText2 = uicontrol( hFig2, 'Style', 'text', 'Position', [10 10 125 25], 'String', 'Some other text' );
hTextLink = linkprop( [hText1, hText2], 'String' );
set( hText2, 'String', 'Yet another string' ); % This should update the first text too
set( hText1, 'String', 'And another string' ); % This should update the second text too

カテゴリ

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