App Designer uitextarea control gives position values not in pixels when window is maximised?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Here is the output. Can this be translated into pixels or any alternatives?
ans =
1.0e+03 *
1.2728 0.7737 0.6092 0.1143
採用された回答
Ajay Kumar
2019 年 11 月 13 日
編集済み: Ajay Kumar
2019 年 11 月 14 日
When I do this:
fig = uifigure;
txa = uitextarea(fig);
txa.position
I get the Output as 100 100 150 60 which are pixels.
7 件のコメント
That is true but there is some weirdness in MATLAB that it is often there may be other factors that effect it. So, I just tested the code below which does the job, both in normal and maximised. However, the UI for the app I am working is more and there are more controls in that MATLAB may have to consider when doing the "Auto" anchoring of controls, tho the other controls give pixel values which is wierd that it may be only the UITextarea.
The problem is unreproducible, check the zip also tested it in App Designer.
fig = uifigure;
txa = uitextarea(fig, 'position', [10 100 250 100]);
b = uibutton(fig)
b.ButtonPushedFcn = @(src, event)disp(fig.Children(2).Position)
Ajay Kumar
2019 年 11 月 14 日
編集済み: Ajay Kumar
2019 年 11 月 14 日

The app is working perfectly fine with me, as you can see when I click Show Positions button, I can see the position of text area(in PIXELS) in Positions text field.
Also, it works when I maximise the window. Replace the Show Positions callback with
app.PositionsEditField.Value = num2str(fix(app.TextArea.Position));
Also, If you want the components position to be fixed even if window is maximised, you can set the AutoResizeChildren to off
for example
fig = uifigure;
fig.AutoResizeChildren = 'off';
txa = uitextarea(fig, 'position', [10 100 250 100]);
b = uibutton(fig)
b.ButtonPushedFcn = @(src, event)disp(fig.Children(2).Position)
Bereketab Gulai
2019 年 11 月 14 日
編集済み: Bereketab Gulai
2019 年 11 月 14 日
Thanks for your time.
Here is what fix() produced for the numbers that were given by the Position property. Which is does not seem useful.
>> c = [1.2728 0.7737 0.6092 0.1143]
c =
1.2728 0.7737 0.6092 0.1143
>> fix(c)
ans =
1 0 0 0
I am looking to keep it so that it resizes the children, but it should not also change the unit I suppose for specific ones. I have tried applying the unit measurement property to pixels just before calling the Position property of uitextarea.
Bereketab Gulai
2019 年 11 月 14 日
編集済み: Bereketab Gulai
2019 年 11 月 14 日
Apparently the: fix()
fix(app.TextArea.Position)
Did the "fix" so it is now shows pixel values correctly. This problem I supppose is related to the where number editField would show numbers in that representation due too long and this can be resolve by changing "ValueDisplayFormat" property to integer.
FYI:
I came to this conclusion after checking the internal value of the control, using mlapptools, which was intact, only at the higher level was being modified.
I think you are missing out something in c
In the comment above you have considered c as
c = [1.2728 0.7737 0.6092 0.1143]
you are missing to multiply *1.0e+03
which indicates
[1272.8 773.7 609.2 114.3]
which are pixels.
That is correct, they can be restored to correct unit.
Thank you
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Use COM Objects in MATLAB についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
