Display times in App Designer components

34 次查看(过去 30 天)
Matt
Matt 2020-4-15
评论: Matt 2020-4-24
Using App Designer, I want to provide the user of an application with the ability to choose a date and time. The date is easy to achieve with the Date Picker component. I have not been able to find an obvious way to select a time. I could use the Edit Field (Text) component, but that would be too error prone (typos, formatting). I tried to use the Spinner and Edit Field (Numeric) components, but I could not find a way to change the format to a time. The 'ValueDisplayFormat' property of both allows you to create a custom format, but I couldn't figure out how to get a time format in this manner. Is there a way to make that work? I am new to App Designer, so I may be missing something obvious, or maybe App Designer does not give you the flexibility of manual programming or GUIDE. I want to avoid going down one of those paths, but how difficult would it be to make something programatically or using GUIDE to do what I want? How would I then incorporate that into an App Designer project? Are there other ways to allow a user to input times to applications created with App Designer? Maybe some creative way of using the existing components? Can you make your own custom components for use in App Designer? If so, what does that entail? Do people post components in the File Exchange?
Thanks for the help.
Matt
  1 个评论
Peng Li
Peng Li 2020-4-15
"or maybe App Designer does not give you the flexibility of manual programming or GUIDE."
Just a commment that appdesigner definitely gives more flexibility than GUIDE. One example is the access of gui data using GUIDE is annoying as every time you have to remember this. OO offers clearly better way to access class properties.
appdesigner results in similar structure as you manually program an interface based class. If you check the appdesigner code, all interface components are generated within the CreateComponents methods, which is what you need to manually do if you start from scratch.
For the time part, I don't have a better clue. Hope someelse has. What I have done before is to place a simple edit field with some default message like HH:mm:ss to show users how to format the time. But unfortunately matlab doesn't have a good way to make this message a placeholder like what you have in Word/Powerpoint etc.

请先登录,再进行评论。

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-4-15
Although the time picker is not available in App designer, the attached app shows a workaround using UITable.
  11 个评论
Ameer Hamza
Ameer Hamza 2020-4-18
Pressing Tab key does not do anything in my case. I am using a macOS, and there might be a difference between platforms. However, pressing enter after typing a 4 does not revert back to 01. Please see this gif. You can consider adding breakpoints in the callback function and see what are the values of variables after you change the value in any cell
Matt
Matt 2020-4-24
I ended up using 3 spinner components side-by-side as a workaround. I was able to enter values the way I wanted on my system.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by