How to initialize PopupMenu with first element on each dynamic update – Business Intelligence Info

Iwroteafunction,whichlistsdirectories,whichmaycontainmodelfilesinthefollowingformat

{dirpath1-dirname1,dirpath2-dirname2。

i。

e。

informat,suitableforPopupMenufunction。

ThenIwroteafunction,whichlistsmodelfilesingivendirectoryinthesameway

{filepath1-filename1,filepath2-filename2,

Iwaswishingtoselectdirectoryinfirstpopupandthenselectfileinsecondpopupandwrote

PopupMenu[Dynamic[dir],GetModelDirectories[]]

Dynamic[PopupMenu[Dynamic[fil],GetMatFiles[dir]]]

Itworked,butpartially:ifIchangefirstpopup,secondpopupturnsempty

andIneedexplicitlyselectsecondpopup

Isitpossibletoinitializesecondpopupautomaticallytothefirstiteminthelist?

Letsblockads!

(Why?

)

RecentQuestionsMathematicaStackExchange