The following code (from this forum) works as expected, allowing a quick selection of an indicator from a very long list of PopupMenu:

ClearAll[searchPopup, selection];
searchPopup[Dynamic[selection_], list_List] := 
DynamicModule[{x = ""}, 
Grid[{{InputField[Dynamic[x], String, Appearance -> "Frameless", 
   ContinuousAction -> True, FieldHint -> "Search", 
   FieldSize -> 10], Spacer[5], 
  Dynamic[PopupMenu[Dynamic[selection, (selection = #; x = #) &], 
     z_String /; StringMatchQ[z, x ~~ ___, IgnoreCase -> True]], 
    Null, Opener[True, Appearance -> Small]], 
   TrackedSymbols :> {x}]}}, Alignment -> {{Right, Left}, Center},
 Background -> White, Frame -> True, 
FrameStyle -> GrayLevel[0.8]]];
selection = "";
searchPopup[Dynamic[selection], indicatorList]

I tried to integrate this code into the Manipulate[...] given below:

categoryList = {"status", "subregion", "country"};

  ds[GroupBy[Key[categoryList[[category]]]], All, {var1, var2}],
  PlotTheme -> "Business",
  PlotLabel -> {var1  ,   var2},
  FrameLabel -> {var1, var2},
  ImageSize -> 500,
  AspectRatio -> 1/1.62
 {{category, 1, "categories"}, 
  Thread[Range[Length[categoryList]] -> categoryList], 
  ControlType -> PopupMenu},
 {{var1, indicatorList[[1]], "X-axis"}, indicatorList, 
  ControlType -> PopupMenu},
 {{var2, indicatorList[[2]], "Log[Y-axis]"}, indicatorList, 
  ControlType -> PopupMenu}

My question is how to integrate:

searchPopup[Dynamic[selection], indicatorList]

into the above Manipulate. I have already made a few attempts but did not work. The list of indicatorList is ready and a very long one. Data is not relevant to the question. I like to receive guidance for the integration concerned.

EDIT Here it is a short list of indicatorList:

indicatorList= {"Population", "Poverty headcount", "GNI, Atlas     
method", "GNI per capita", "GNI (current $)", "GNI per capita",
"Income share held by lowest 20%", "Life expectancy at birth",
"Fertility rate", "Adolescent fertility rate", "Contraceptive 
prevalence", "Births attended by skilled staff", "Mortality  
rate, under-5", "Prevalence of underweight", "Immunization", 
"Primary completion rate", "School enrollment", "School 
enrollment, primary", "Prevalence of HIV", "Forest area", "Water 
productivity", "Energy use", "CO2 emissions", "Adolescents", 
"Adolescents (age 15 years)", "Environmental performance index", 
"INFORM risk index"};


Here is a revised Manipulate:

{var1, var2},
{{var1, indicatorList[[1]], "X-axis"}, indicatorList, 
ControlType -> PopupMenu},
{{var2, indicatorList[[2]], "Log[Y-axis]"}, indicatorList, 
ControlType -> PopupMenu}
  • 1
    $\begingroup$ Please give a small example of "indicatorList" $\endgroup$ Commented Nov 29, 2021 at 16:15
  • $\begingroup$ @Daniel Huber: In a few minutes, I will edit the question with a small list. $\endgroup$ Commented Nov 29, 2021 at 16:38
  • $\begingroup$ I am sorry, but there is still a problem, "ds" is not defined. $\endgroup$ Commented Nov 29, 2021 at 16:58
  • $\begingroup$ @Daniel Huber: My purpose was not really to make ListPlots but only to know how to integrate two pieces of codes. I will remove ListPlot from the existingManipulate and give a revised workable Manipulate. $\endgroup$ Commented Nov 29, 2021 at 17:20
  • $\begingroup$ @Daniel Huber: I revised the Manipulate. $\endgroup$ Commented Nov 29, 2021 at 17:25

2 Answers 2



Manipulate[{var1, var2}, 
 {{var1, indicatorList[[1]], "X-axis"}, searchPopup[#, indicatorList] &}, 
 {{var2, indicatorList[[2]], "Log[Y-axis]"}, searchPopup[#, indicatorList] &}]

enter image description here

  • 2
    $\begingroup$ One of my papers has been accepted for publication by the Journal of Economic Structures (forthcoming early next year). There I acknowledged your code and provided the https link to the MMA. Thank you again for your utmost help. $\endgroup$ Commented Nov 29, 2021 at 20:37

If I understand correctly, you want to incorporate a popup menu in a manipulate. This can be easily accomplished with built in functions without additional code.

Here is a simple example:

list = {"item1", "item2", "item3"};
 "My choice is: " <> choice, {{choice, "item1", "Item: "}, 
  PopupMenu[#, list] &}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.