필터 지우기
필터 지우기

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 CenterFile Exchange에서 Maintain 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