custom UI component issues

조회 수: 10 (최근 30일)
Nathan Bblanc
Nathan Bblanc 2021년 2월 9일
댓글: Nathan Bblanc 2021년 4월 18일
Update: I solved this for now by adding a line to the "update" function that sets the Parent of the panel to be the Parent figure rather than the object itself. namely:
set(obj.Panel,'Parent',obj.Parent)
however I am worried that this might cause bugs in the future
original question:
I am trying to create a custom UI component. so far I simply tried to integrate a panel with a UIImage.
however, my custom component stubbornly refuses to appear on the screen. in other cases it appears on the screen but the title of the panel is not there.
I am attaching my code, as well as my resulting figures. in my main script I also run the exact same commands directly and the figure indeed appears.
Thanks in advance
Nathan

채택된 답변

Greg
Greg 2021년 4월 15일
" set(obj.Panel,'Parent',obj.Parent)
however I am worried that this might cause bugs in the future"
You're absolutely right. This is not a good idea.
Your problem is that the panel's default units are "normalized" so setting anything outside the bounds of 0 and 1 results in something way off-screen (of the componentcontainer object). In your panel constructor call, set the units to pixels before setting the position property.
Better yet, I strongly encourage the use of uigridlayout. Every componentcontainer I build starts with a grid. Using grids makes nearly every conversation about size and position irrelevant. It also cures practically every situation such as this one - "what's wrong with my component positioning?".
  댓글 수: 1
Nathan Bblanc
Nathan Bblanc 2021년 4월 18일
thank you for your answer Greg. while you are here, I wonder if I could piggyback the question with another one.
is there a way to set a "mouse released" function in my custom component? there used to be one in the old buttons for the guide, but there isn't one in the new uibuttons

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by