AppDesigner: Custom UI Component based on Spinner

2 ビュー (過去 30 日間)
memam
memam 2022 年 1 月 14 日
回答済み: Shivam 2023 年 10 月 16 日
Hello,
how can I create a custom component based on the AppDesigner Spinner with a large up and down button?
Thank you

回答 (1 件)

Shivam
Shivam 2023 年 10 月 16 日
Hi Memam,
I understand you want to create the custom component based on Spinner of Appdesigner.
You can follow the below workaround to make the custom spinner.
  • Open a new app in appdesigner.
  • Drag and drop 2 "Button" components and 1 "Edit Field(Text)" component from the component library.
  • Set the "Value" property to 0 of the "Edit Field(Text)" component.
  • Fill the "Text" field of the "Button" component with upward and downward symbols.
  • Create a callback function for the UP button, which increments the EditField.Value by one every time the up button is pressed. You can follow the code:
% Button pushed function: Button
function ButtonPushed(app, event)
currVal = str2double(app.EditField.Value);
newVal = currVal+1;
app.EditField.Value = num2str(newVal);
end
  • Repeat the above step for the DOWN button, which decreases EditField.Value by 1.
  • Position and resize the buttons and text components and run the app to see the result.
I hope the detailed steps help you.
Thanks,
Shivam

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by