uitable tooltip for long entries

조회 수: 3 (최근 30일)
Mario Malic
Mario Malic 2023년 2월 15일
편집: Jacob Mathew 2025년 7월 9일
Hello guys,
In uitable component, when there is not enough room for text to display, tooltip will be displayed with the full text. When the content of a cell is an numeric or cell array, it will show i.e. 1x4 cell. Is it possible to modify the tooltip functionality to display the content of these cells in a textual way such as below?
{'3', '2', 'text', 1}
Is there some callback that I haven't seen?
Thanks.
  댓글 수: 2
Sachin
Sachin 2023년 2월 16일
Your problem is not clear. What do you want ?
Mario Malic
Mario Malic 2023년 2월 16일
편집: Mario Malic 2023년 2월 16일
Thank you for the reply.
The tooltip in the picture below is displayed because it does not fit the column width.
I want to display the tooltip for this 1x2 cell to the cell contents {'3', '2'}.

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

답변 (1개)

Jacob Mathew
Jacob Mathew 2025년 6월 30일
편집: Jacob Mathew 2025년 7월 9일
While this is not a direct solution on how to update the UI Tool Tip, there is a workaround where you can convert the cell array into string and print that instead. This allows the default UI Tool Tip behaviour to function as expected and display the whole content if there is overflow. You convert the cell array contents into string using the code below:
(Credit to @Stephen23 for suggesting formattedDisplayText() function as a replacement for evalc())
app.UITable.Data={'sample'};
myCellArray = {'1','2','text',4};
cellStr = char(formattedDisplayText(myCellArray));
app.UITable.Data(:,2)={cellStr};
The output is as follows when the above code is put into the StartupFcn() of the App:
This matches how the output would look like when you create a cell array and display it in the command line:
myCellArray = {'1','2','text',4}
myCellArray = 1×4 cell array
{'1'} {'2'} {'text'} {[4]}
  댓글 수: 2
Mario Malic
Mario Malic 2025년 7월 9일
Appreciate the effort, however, evalc should be avoided.
Stephen23
Stephen23 2025년 7월 9일

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

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by