Вы находитесь на странице: 1из 3

AddingtoGUIsubmenusonthefly

Subject:AddingtoGUIsubmenusonthefly
From:richard.walledge@sti...
Date:13Aug,200023:39:10
Message:1of2
Replytothismessage
AddauthortoMyWatchList
Vieworiginalformat
Flagasspam

I'musingMATLAB4.0,andwanttodothefollowing:

IhaveaGUImenu,withascrolloutsubmenu,withinitiallyoneitem
onit.Whenyouselectthisitem,aseconditemonthesamesubmenuis
created.

Atthispoint,iftheseconditemisselected,athirditemis
created,BUTifthefirstitemisselectedagain,somethingelse
happens.

Whenthereare3items,onlythethirdonecreatesa4thitem,butthe
first2dosomethingelse...

Idonotwanttouseanexternalfunction,butI'vetriedusingaFor
loop,butIcan'tgetittowork...

Anyhelpviaemailappreciated....

Thanksinadvance,

Richard
MATLABNewsgroup

Subject:AddingtoGUIsubmenusonthefly
From:KevinMcGill
Date:14Aug,200010:42:14
Message:2of2
Replytothismessage
AddauthortoMyWatchList
Vieworiginalformat
Flagasspam
Richard,

I'mnotsurewhatyoumeanbyanexternalfunction,but
thestandardswitchyardtechniqueshouldwork.Thisexample
worksinMatlab4.2c.1ontheMac.Call"myhandler"
initially
withnoargumentstocreatetheparentmenuandthefirst
menuitem.Then,"myhandler"getscalledviacallback
whenevertheuserselectsamenuitem.Hopethisgives
youanideahowtosolveyourproblem.

Kevin

functionmyhandler(i)
globalM
ifnargin==0
figure(1)
M=uimenu(1,'label','MyMenu')
uimenu(M,'label','Item1','callback',...
'myhandler(1)')
return
end
n=length(get(M,'children'))
ifi==n
uimenu(M,'label',sprintf('Item%i',n+1),...
'callback',sprintf('myhandler(%i)',n+1))
else
fprintf('Item%iselected.\n',i)
end

MATLABNewsgroup
*SentfromAltaVistahttp://www.altavista.comWhereyoucanalsofindrelatedWebPages,Images,

Audios,Videos,News,andShopping.SmartisBeautiful

FeedforthisThread
AddtoMyWatchList

WhatisaWatchList?

TagsforthisThread
Notagsareassociatedwiththisthread.

Whataretags?
Atagislikeakeywordorcategorylabelassociatedwitheachthread.Tagsmakeiteasierforyoutofindthreadsof
interest.

Anyonecantagathread.Tagsarepublicandvisibletoeveryone.

19942016TheMathWorks,Inc.

MATLABNewsgroup

Вам также может понравиться