give the name of the uicontrol thats calling a function as an argument

5 ビュー (過去 30 日間)
jeff wu
jeff wu 2012 年 3 月 5 日
hi, i got the following code:
S.pushbutton1 = uicontrol('Parent',hp,'style','pushbutton',...
'unit','pix',...
'position',[10+10*gr(1) mws(4)-60-gr(2) gr(1) gr(2)],...
'string','Einstellungen]',...
'backgroundcolor',[1 1 1],...
'fontsize',10,...
'callback',{@pbStab_call,?????});
S.pushbutton2.. = uicontrol(....
...
there are mor pushbuttons and other uicontrols which could call that function.
i want to write a function that can be called by all theese PB's for example if several edit tags got numerical value input. so i would need in the function the name of the uicontrol thats calling it. i hope this is understandable.
function[] =pbStab_call(varargin)

採用された回答

Walter Roberson
Walter Roberson 2012 年 3 月 5 日
No, that cannot be done. uicontrols have no name.
A uicontrol can have a Tag set for it.
If you want to pass an addition parameter (say a string) with the callback, then
[...]
'callback',{@pbStab_call,'Blind Lemon Morton'}
then you can receive it in your callback function:
function pbStab_call(src, evt, objname)
fprintf('Let''s welcome %s to the stage!\n', objname);
end
  2 件のコメント
jeff wu
jeff wu 2012 年 3 月 6 日
thx for your answer
thats a bit disapointing though, :-)
have i chosen the right way for a programm that coult become big??
function [] = Woody()
scrsz = get(0,'ScreenSize');
mws=[0 100 scrsz(3)-60 scrsz(4)-140];
S.fh = figure('position',mws,...
hp = uipanel('Title','Schnittkräfte',...
and then there a r a bunch of uicontrols that are included in the panel in order to be able to make them invisible at once.
Walter Roberson
Walter Roberson 2012 年 3 月 6 日
What would you do with the "name" of the uicontrol if it had a name? Note that the "name" of a graphics object is not the same as the variable that stores it! For example, a figure can have a "Name" completely different than the variable used to store the figure number.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by