Flip vertical uislider such that negative values are displayed at the top
3 次查看(过去 30 天)
显示 更早的评论
In a appdesigner app, I have an uislider component. The callback of which controls a mechanical stage which moves in the vertical direction. The stages' coordinate system is intentionally such, that the positive values correspond to the stage being lowered.
Now, it seems to me like you cannot have an uislider component that has its positive values at the bottom and the negative ones at the top, can you? At least, I cannot flip the Limit-property...
3 个评论
回答(1 个)
Image Analyst
2020-5-14
Why can't you just get the slider value, adjust it, and display it:
sliderValue = app.sldCoordinate.Value;
% Find out where the thumbbar is with respect to the max and min (top and bottom respectively).
range = app.sldCoordinate.Max - app.sldCoordinate.Min;
percentage = (sliderValue - app.sldCoordinate.Min) / range;
% Flip it
newSliderValue = app.sldCoordinate.Min + percentage * range;
% Set caption on some label
app.txtCoordinates.String = sprintf('Coordinate = %f', newSliderValue);
The above code is just off the top of my head and is untested.
2 个评论
Image Analyst
2020-5-15
I'm not using App Designer yet because, last time I checked, the debugging was difficult because the code window is in a different app than the workspace and command window, unlike the way it is with GUIDE. That's a deal breaker for me. I've talked in person with the App Designer developer team while I was at the Mathworks and they understood my reservations and I hope to think one day we'll be able to have them all in the same window.
Regarding #1, I'm not very familiar with App Designer, but as far as I know, I would expect every control to have a callback function. Are you saying that there is no callback function for the slider? Or that it vanishes after the GUI has fully loaded? Or just that there is no way to call it after the GUI has come up to set the caption properly? I did try to put a vertical slider on and reverse the max and min limits but it says that's not allowed. If it's a deal breaker for you, you can revert to GUIDE. I also suggest you call them and put it on the list of suggested feature enhancements. Please also mention my request for having workspace, code, and command panels all in one app, it you remember.
另请参阅
类别
在 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!