Borrar filtros
Borrar filtros

Is there a way to make msgbox copy-paste?

11 visualizaciones (últimos 30 días)
Andrew
Andrew el 17 de Abr. de 2024
Respondida: Voss el 17 de Abr. de 2024
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?

Respuestas (1)

Voss
Voss el 17 de Abr. de 2024
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.

Categorías

Más información sobre Maintain or Transition figure-Based Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by