フィルターのクリア

How to "wrap text" on pushbutton string?

19 ビュー (過去 30 日間)
Epri Pratiwi
Epri Pratiwi 2020 年 8 月 17 日
コメント済み: Epri Pratiwi 2020 年 8 月 17 日
I have a long tittle for a file. When I tried to show the tittle on pushbutton, it become like this. I want the rest of tittle goes down or look like in "wrap text" mode (just like in Excel).

採用された回答

Walter Roberson
Walter Roberson 2020 年 8 月 17 日
編集済み: Walter Roberson 2020 年 8 月 17 日
Create a figure. Create a uipanel within the figure. Create a uicontrol style text or edit with Max set greater than 1, with parent set to the uipanel. Set the Position property to the height and width you want the pushbutton to have, plus a magic number margin to take into account the outside and decoration of uicontrol style text. Make sure the uicontrol has the right font name and font size that you will be using.
Now wraptext() with the control and the text you want for the button. You will get out a cell array of character vectors that contains the split text.
Option 1:
Now set the string property of the uicontrol to the wrapped text cell array. Set the Position of the uipanel to just enclose the uicontrol. And then use saveas() or print() or exportgraphics() to capture a copy of the rendered text and write out to a file and imread the file, /Or capture() the uipanel into an array. With the array on hand either way, set the CData property of the pushbutton to have an image of the text
Option 2: take the cell array of character vectors and use insertText from the Computer Vision Toolbox to render the text into an array. Then set the CData property of the pushbutton to be the image of the wrapped text.
Afterwards, clean up.
You might have noticed here that:
A) you cannot just pass in an array size and text and ask to wrap it, or render it in wrapped form;
B) pushbuttons do not support multi-line labels, so you have to put in a picture of the text.
But never let it be said that I didn't tell you how to do the task. It is possible.
You might want to consider separating the label into a uicontrol style edit with Enable set to disable. When you do that, you will get scroll bars but the user will not be able to edit. Then put a button without a label.
  1 件のコメント
Epri Pratiwi
Epri Pratiwi 2020 年 8 月 17 日
Thanks for the info! I will try to use image for the pusbutton that contains the tittle.

サインインしてコメントする。

その他の回答 (1 件)

Vladimir Sovkov
Vladimir Sovkov 2020 年 8 月 17 日
編集済み: Vladimir Sovkov 2020 年 8 月 17 日
Use the cell array with entries containing text fragments to be shown in separate strings.
  1 件のコメント
Epri Pratiwi
Epri Pratiwi 2020 年 8 月 17 日
I don't think if it's possible. Making a multiline text display is not possible on pushbuttons.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by