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

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 Comments

Have you tried to get java object handle and it didn't work as it said in Yair's blog?
Could you please share the code?
I have trie java handle, but not sure if I used the one you are pointing me to.
Could you send me the link for the Java handle you were mentioning
if you just need an enclosing box then you can put uicontrol text inside uipanel.
Good idea! so this panel and uicontrol will share the same size right? or in another word, how shall I ensure I put the text dirctly on top of the panel?
Make units for the uicontrol 'normalized' and position [0 0 1 1], and parent it to the uipanel.
thanks for providing more help!
What value shall be use for unit as 'char' since my code need uicontrol to have unit as 'char'
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.
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.

Sign in to comment.

Answers (1)

Luna
Luna on 24 Jan 2019
Edited: Luna on 24 Jan 2019
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 Comments

This one doesn't work, I tried to findjobj after uicontrol been created, and then for that particulart label, set a ToolTipTest, but I sitll didn't see the tooltip
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.
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

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Asked:

on 23 Jan 2019

Commented:

on 24 Jan 2019

Community Treasure Hunt

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

Start Hunting!