Label Positions Shifting When App Runs

14 Ansichten (letzte 30 Tage)
Christopher McNamara
Christopher McNamara am 23 Mai 2019
Hello,
I am designing an App in App Designer and am gettings some strange behavior with Components shifting themselves so they appear different than they do in Design View when the app is running.
As an example, I have a set of tabs in my app and a text label is located in the same position on each tab. When the user cycles between tabs, these labels should appear in the same position but with different text. This looks correct when viewing the app in the Design window.
When the application is run however, one of the labels physically shifts to a new position vertically and appears closer to the tab group than it does in the design window.
What is even stranger is if I debug the app and probe the positions, the position of the labels really is shifted but the ones appearing in the "wrong" location retain their original set values from the Design window. For example:
DESIGN Mode:
app.Lablel1.Position = [100 100 100 100]
app.Label2.Position = [100 100 100 100]
RUNNING Mode (debug):
app.Lablel1.Position = [100 120 100 100]
app.Label2.Position = [100 100 100 100]
Clearly, this shows that Label 1 has shifted by 20 units from its specified location in the App Designer but it appears to be in the correct position when running whereas the Label 2 retains its specified value but appears to be in the wrong location (actually is visually shifted).
I have Autoresize on by default for all components so I don't think this is what is causing the problem.
Can anyone replicate this or has noticed this behavior?
  3 Kommentare
Christopher McNamara
Christopher McNamara am 24 Mai 2019
Hi Alice,
Thanks for the response. Unfortunately I can't share it as is, I'll need to strip it down to take out IP/ITAR to do so. I would need some time to do this.
I did find a work around that has fixed my issue although it seems like the behavior I am seeing should not occur. It appears to have something to do with the re-sizing of the application window during initialization. I think one thing I also forgot to mention is that I have a menu bar on the app figure as well that I think is related to the issue.
I fixed the issue by:
  1. In the Design View, set the app's figure properties to have Resize and AutoResizeChildren off (unchecked).
  2. In the app's StartUpFcn(), I changed the size of the app figure manually in the vertical direction by using the command as the last portion of the start up function to execute app.UIFigure.Position(4) = app.UIFigure.Position(4) + 22. The 22 pixel increase is because I noticed that although in Design View, the UIFigure height was set to 1150 pixels, it actually was only starting at 1128 pixels. I can see this command work during startup because my Tabs are hidden by the menu bar at first and then become visible after this command executes -- I believe the height of the menu bar is 22 pixels possibly but cannot verify.
  3. Re-enable resizing with app.UIFigure.Resize = 'on' and app.UIFigure.AutoResizeChildren = 'on'
Hopefully this helps identify whatever problem may be occurring. I will try to post a stripped version of my app when I have some time.
Karun Mathiazhagan
Karun Mathiazhagan am 26 Mai 2019
Bearbeitet: Karun Mathiazhagan am 26 Mai 2019
Hello Christopher,
As and when you are able to reduce the issue, please feel free to write to us at support@mathworks.com and the support team should be able to help you narrow down the issue further.
Best,
Karun

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by