Filter löschen
Filter löschen

duplicate tab:how know reference object?

1 Ansicht (letzte 30 Tage)
piero
piero am 23 Okt. 2023
Kommentiert: piero am 25 Okt. 2023
obj = allchild(app.Tab_X);
newtab = uitab(app.TabGroup,'Title',"XX"); % Create a new tab with the same title
copyobj(obj,newtab);
but what is the reference this object?
I don't think they have the same name as the original' ...
example: in this example i duplicate chart in other tab..but how can i know the referenze this Axis?
  1 Kommentar
piero
piero am 23 Okt. 2023
Bearbeitet: piero am 23 Okt. 2023
i find this solution:
h=findobj(newtab)
h =
9×1 graphics array:
Tab (CL)
GridLayout
UIAxes (Equity)
UIAxes (Equity)
UIAxes (Equity)
UIAxes (Equity)
Label (gg Vis)
NumericEditField (250)
Button (DRAW)
h(3) is the reference axis
or esist better method to catch it?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Voss
Voss am 23 Okt. 2023
Better than findobj() is to capture the output from copyobj():
new_obj = copyobj(obj,newtab);
  12 Kommentare
Voss
Voss am 25 Okt. 2023
So you have 6 Draw buttons and you need to make each one do something different, is that right?
(Option 1) When you create each Draw button (e.g., by copyobj) set the new button's callback to an appropriate function.
(Option 2) Alternatively, have each Draw button execute the same callback and figure out what to do inside that callback, based on which tab contains the Draw button whose callback is currently executing.
Option 1:
newobj = copyobj(allchild(tab),newtab);
newdrawbutton = % figure out which element of newobj is the new Draw button
switch newtab
case app.FDAXtab % handle to a tab
newdrawbutton.ButtonPushedFcn = @callback_for_FDAX_draw;
case app.Aggregatetab % handle to another tab
newdrawbutton.ButtonPushedFcn = @callback_for_Aggregate_draw;
case % etc.
% ...
end
Option 2:
function draw_button_callback(app,evt)
switch get(gcbo,'Parent')
case app.FDAXtab % handle to a tab
% code for what should be done when Draw button
% in FDAX tab is pushed goes here
case app.Aggregatetab % handle to another tab
% code for what should be done when Draw button
% in Aggregate tab is pushed goes here
case % etc.
% ...
end
end
piero
piero am 25 Okt. 2023
thx

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Identification finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by