필터 지우기
필터 지우기

TooltipString won't show if uicontrol Enable is not 'on'

조회 수: 4 (최근 30일)
Kat Lee
Kat Lee 2019년 1월 23일
댓글: Kat Lee 2019년 1월 24일
Hey MATLAB users,
I have a Edit style uicontrol label, which has set 'enable' to 'intactive' to make it not editable.
But now, I also want to add a tooltipString for this ui label, but since it's set to inactive, nothing will show.
I really dont want to use 'text' since there is no outline for the label box.
Is there anyway I could add TooltipString for this case.
there is one ticket about it, but didn't solve my question really well: https://www.mathworks.com/matlabcentral/answers/81029-tooltipstring-not-displaying-when-button-is-disabled
  댓글 수: 8
Walter Roberson
Walter Roberson 2019년 1월 23일
At the time you create the uipanel you can give char units and Position to it, and then create the uicontrol with units normalized and size [0 0 1 1]. After that set() the uicontrol to units char if you need to.
Kat Lee
Kat Lee 2019년 1월 24일
This one works !
So far, i guess this is the " best" choice I could have if I want to set to 'interactive' but still want to keep the tooltip.
Hope MATLAB could extend this uicontrol with more option for users.

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

답변 (1개)

Luna
Luna 2019년 1월 24일
편집: Luna 2019년 1월 24일
Here you can get the object, set editable property of the Java object as false like below and then add a tooltip.
hEditbox = uicontrol('String','Edit Text','Style','edit');
drawnow;
jEditbox = findjobj(hEditbox); % gets the java object handle
set(jEditbox,'Editable',false); % this will disable your editbox
set(jEditbox,'ToolTipText','Text is inactive for a reason'); % this will create a tooltip string
  댓글 수: 3
Walter Roberson
Walter Roberson 2019년 1월 24일
I seem to recall that there are some race conditions where a java object might not be allocated until the graphics object is rendered -- the drawnow() that Luna shows.
Kat Lee
Kat Lee 2019년 1월 24일
thanks for the information
I am not very willing to use drawnow and findjobj, since it will slow down the speed a lot if we generating a bunch of ui button

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

카테고리

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