Unable to clear editField more than once
1 次查看(过去 30 天)
显示 更早的评论
I am creating a typing test on the MatLab AppDesigner. I have simplified it down to a core problem. I have placed an EditField on the screen and have created this code for the function EditFieldValueChanging(app,event):
currentText = event.Value;
if contains(currentText,'test')
app.EditField.Value = ' ';
disp('good job')
end
I have two issues: firstly, I cannot set the app.EditField.Value to nothing (i.e. ''). I tried this with a TextArea and it did work however, so I have found a workaround. Secondly and the main issue, is that once it clears the text, it only works once. If I type 'hello' again into the text box, it displays 'good job' but does not clear the text the second time around. I really appreciate any help.
1 个评论
Mario Malic
2024-4-24
It's not recommended to do so as it may lead to unexpected behaviour - https://uk.mathworks.com/help/matlab/ref/matlab.ui.control.editfield-properties.html#buh_e24-58-ValueChangingFcn
This might work - https://uk.mathworks.com/matlabcentral/answers/2109246-how-to-detect-programmatically-induced-value-changes-of-uidropdown
Hopefully someone else might also add some insights to this issue.
回答(1 个)
Neha
2024-5-6
Hi Max,
I understand you are facing an issue while clearing 'EditField' object's value in MATLAB App Designer.
To help you work around this issue, you might consider trying either of the following suggestions:
- Change the window focus mode to "click" instead of "mouse" in the settings.
- Switch the desktop environment to XFCE.
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!