uifigure: position and outerposition [2016a]

20 ビュー (過去 30 日間)
Carlos Aguilar
Carlos Aguilar 2016 年 5 月 5 日
コメント済み: Taylor 2024 年 10 月 25 日 16:47
Hi,
I want to place a dialog created with uifigure so it fits half of the screen (including title bar and outer edges) but the property Position excludes them (unlike Position vs OuterPosition in figure). Any workaround to get the full extent of the uifigure?
uiFig = uifigure;
% returns 0...
uiFig.Position-uiFig.OuterPosition
Thanks, Carlos
  1 件のコメント
Sebastian
Sebastian 2024 年 10 月 23 日 9:56
Any progress on this one? I still have the same issue in 2024 ...

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

回答 (1 件)

Taylor
Taylor 2024 年 10 月 24 日 19:54
Since there is no OuterPosition property for UIFigures, you will have to do some math. I would recommend using this method to get the size of your screen. Then create your UIFigure, and use the WindowState property to set the figure to "maximized". At this point you can calculate the size of the borders and title bar by taking the difference between the screensize and the Position property. From there you should have the information you need to create a UIFigure that fits half of the screen including title bar and outer edges.
  2 件のコメント
Sebastian
Sebastian 2024 年 10 月 25 日 13:24
"Since there is no OuterPosition property for UIFigures"
This is not entirely correct. The property itself does exist, but it does not provide the correct data and it is not assignable. The value of OuterPosition returns the same value as Position.
"use the WindowState property to set the figure to maximized"
This was my first thought as well. But the problem I see is, that the screen size does not take the OS Taskbar into account, and thus would be inaccurate as well. Another issue is that maximizing the figure will result in the user recognizing the "flickering" due to the window state being changed.
Taylor
Taylor 2024 年 10 月 25 日 16:47
Try this. It takes a second for the figure to actually generate which is why the pause statement is in there.
f = uifigure("Units","normalized", "WindowState","maximized");
pause(3.5)
f.Position = [f.Position(1) f.Position(2) f.Position(3)*.5 f.Position(4)]

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

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by