フィルターのクリア

Is there a way to make msgbox copy-paste?

11 ビュー (過去 30 日間)
Andrew
Andrew 2024 年 4 月 17 日
回答済み: Voss 2024 年 4 月 17 日
I want to be able to use the command msgbox and then have users be able to copy-paste the text being displayed from the msgbox. Is there a way to do this?

回答 (1 件)

Voss
Voss 2024 年 4 月 17 日
I don't think there's a way to do that using msgbox, but you can copy text from an 'edit'-style uicontrol, such as is created by inputdlg. For example:
msg = 'here is your message';
inputdlg('','',1,{msg},'on')
The message is already selected when the dialog window opens; hitting ctrl+c when the window appears will copy the message to the clipboard.
You can also copy text from a 'listbox'-style uicontrol, such as is created by listdlg. For example:
msg = 'here is your message';
listdlg('ListString',msg,'ListSize',[200 26],'SelectionMode','single');
The message is already selected when the dialog window opens (avoid double-clicking since that closes the window); hitting ctrl+c when the window appears will copy the message to the clipboard.
If your message has multiple lines, you can increase the listbox height and use 'SelectionMode','multiple' to allow the user to select all the lines at once:
msg = sprintf('here\nis your\nmessage'); % some multi-line message
listdlg('ListString',msg,'ListSize',[200 50],'SelectionMode','multiple');
Besides using inputdlg or listdlg, another option would be to make your own function to display a modal figure or uifigure with a uicontrol (e.g., 'edit'-style or 'listbox'-style) or uitextarea (uifigure only) in it.

カテゴリ

Help Center および File ExchangeMaintain or Transition figure-Based Apps についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by