App designer push button and list option

Hello, I was wondering how to turn off push button. Which forces the user to make a selection from a list on that same screen. Once the selection has been made then the push button turns on.

 Accepted Answer

Voss
Voss on 8 Nov 2022

13 Comments

Hello, i have tried that and it isnt working.
i want the user to select an option on the list.
When they do that the push button becomes enabled, and now they can use the push button, the issue is that i am using app designer so the intergration seems to not work.
i have attached a screenshot.
thank you.
"i have attached a screenshot."
Where?
% Callbacks that handle component events
methods (Access = private)
% Callback function
function ListBoxValueChanged(app, event)
end
% Value changed function: ListBox
function ClicktocontinueButtonPushed(app, event)
end
end
% Component initialization
methods (Access = private)
i apologize it didnt include the screenshots for some weird reason, but i have attached the areas that seems to be causing the issue
Voss
Voss on 8 Nov 2022
Edited: Voss on 8 Nov 2022
Inside the listbox ValueChangedFcn (a.k.a., "callback") is where you'd set the 'Enable' state of the uibutton.
It's not clear to me which of those two functions is intended to be the listbox callback; the name of ListBoxValueChanged suggests that that's it, but the comment before ClicktocontinueButtonPushed says that's it, but its name suggests it is the uibutton callback.
It may be that these functions are not associated properly with their respective controls.
I have made adjustment to the code and corrected the error the whole point is that when a selection on the list box is made then the pushbutton becomes enabled.
The code is still not working. it looks like this now. Thank you.
% Callbacks that handle component events
methods (Access = private)
% Value changed function: ListBox
function ListBoxValueChanged(app, event)
value = app.ListBox.Value;
if app.ListBox.Value =='18-28';
app.ClicktocontinueButton,'Enable',"on"
end
end
end
@Nwasinachi do not compare strings like this
if app.ListBox.Value =='18-28';
if strcmpi(app.ListBox.Value, '18-28')
Just tried that and the if loop doesnt seem to be working at disabling the pushbutton and reenabling it when an option on the list is clicked.
@Nwasinachi: This syntax is incorrect:
app.ClicktocontinueButton,'Enable',"on"
It should be like this:
app.ClicktocontinueButton.Enable = 'on'
or this:
set(app.ClicktocontinueButton,'Enable','on')
Thank you so much. it worked.
You're welcome! If you have any other questions, let me know. Otherwise, please "Accept this Answer". Thanks!
i do have another question regarding app designer and merging several m.lapp into one m.lapp.
@Nwasinachi: It's probably best to post that as a new question.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Asked:

on 8 Nov 2022

Commented:

on 10 Nov 2022

Community Treasure Hunt

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

Start Hunting!