フィルターのクリア

Child item with an x position greater than its parent panel's width still appears inside it

1 回表示 (過去 30 日間)
John F
John F 2022 年 4 月 26 日
編集済み: Bruno Luong 2022 年 4 月 26 日
I get the width of a panel in pixels like this:
set(MyPanel,'units','pixel')
pos = MyPanel.Position;
set(MyPanel,'units','normalized')
The width comes back as 510 px, yet a child of this panel that has an x position of 600 or more still appears inside the panel. How is this possible?
Edit to provide a minimum working example and steps to reproduce the problem:
Step 1: Create an app using the "2-Panel App with Auto-Reflow" template
Step 2: Set startupFcn to the following:
function startupFcn(app)
drawnow
fig_position = app.UIFigure.Position;
fig_width = fig_position(3);
fig_height = fig_position(4);
app.GridLayout.ColumnWidth = {0.54*fig_width, 0.46*fig_width};
app.GridLayout.RowHeight = fig_height;
app.UIFigure.WindowState = 'maximized';
MyPanel = uipanel(app.LeftPanel,"Units","normalized","Position",[0 0.5 1 0.3]);
pos = getpixelposition(MyPanel);
pos3 = app.LeftPanel.Position;
pos2 = getpixelposition(app.LeftPanel);
end
Step 3: Set a breakpoint at the end of the function and hover over app.LeftPanel.Position and pos3. You will see that the width value for some reason is different! (See images below)
  13 件のコメント
John F
John F 2022 年 4 月 26 日
@Bruno Luong Yes this is it! For some reason now the width is correct in my app. Thank you!
Bruno Luong
Bruno Luong 2022 年 4 月 26 日
Just keep in mind that App and GUI workflow is Event driven, so concurrent and can be quite surprise if you don't pay close attention.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by