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)
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.
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에서 Develop Apps Programmatically에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
