Possibility of dropdown from a toolbar button in app designer?

2 vues (au cours des 30 derniers jours)
Ian
Ian le 17 Juil 2024
Modifié(e) : Ayush Modi le 18 Juil 2024
I'd like to create a dropdown menu from the upper toolbar of an app that im designing. This dropdown would be to select the color pallete of a figure in the app. Is it possible to have a dropdown menu appear from a toolbar button?

Réponses (1)

Ayush Modi
Ayush Modi le 18 Juil 2024
Modifié(e) : Ayush Modi le 18 Juil 2024
Hi Ian,
I am assuming by upper toolbar, you mean the Push Tool button in the toolbar of the App Designer. Yes, you can have a dropdown menu appear from a toolbar button. Here, are the required steps to achieve the same:
1- Create the Toolbar Button
2- Add a DropDown Component.
3- Create a Callback for the Toolbar Button - To read more about the callbacks in the app-designer, refer to the following MathWorks documentation - https://www.mathworks.com/help/matlab/creating_guis/write-callbacks-for-gui-in-app-designer.html
4- Hide the DropDown Initially - You can change the visibility of the DropDown using the 'Visible' property.
function startupFcn(app)
% Hide the DropDown component initially
app.DropDown.Visible = 'off';
end
5- Show the DropDown When Toolbar Button is Pressed.
function ToolbarButtonPushed(app, event)
% Make the DropDown component visible
app.DropDown.Visible = 'on';
end
% Code that runs after component creation
6- Create a Callback for the DropDown - Write the code to select the color pallete in it.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by