Noneditable "edit text" box to be able to select and copy part of the text

6 views (last 30 days)
Hi,
1. Is there a way to create an "edit text" box, but don't allow it to be edited or modified? I want it so that a part of text can be selected and copied.
I don't want to do it with creating a button to copy entire text into the clipboard. I am trying to get capabilities of selecting a part of text and copying it, not the full text.
h = uicontrol('Style','edit','Position',[10 10 300 100],...
'min',0,'max',2,'enable','on');
str = {['x^2+e^{\pi i} Since its founding in 1984, MathWorks has become the leading ',...
'global provider of technical computing and model-based design ',...
'software. Headquartered in Natick, Massachusetts, MathWorks ',...
'global provider of technical computing and model-based design ',...
'software. Headquartered in Natick, Massachusetts, MathWorks ',...
'currently employs more than 1,000 people worldwide. ']};
set(h,'String',str) % display the string
2. I am also trying to get that equation to show up in tex or latex format, couldn't get around it. That's my second question how to get an equation to show up in an edit text box.

Accepted Answer

Walter Roberson
Walter Roberson on 10 May 2019
  1. You can set a uicontrol style edit 'Enable' to 'inactive' to have a text box that cannot be modified but can be scrolled. Unfortunately, selection is disabled . You would have to go in at the java level to do better.
  2. There is no hope of getting tex or latex in a uicontrol style edit, other than going in at the Java level.
  4 Comments
Baha411
Baha411 on 13 May 2019
Edited: Baha411 on 13 May 2019
Hello Walter,
What do you mean by live script? .mlx file? Can I embed an .mlx file into a GUI panel?
I am still looking for creating an environement where I can print equations, preferabley in latex.
Walter Roberson
Walter Roberson on 13 May 2019
Live Script does refer to .mlx files.
At present, Live Script is useful for creating documents with executable parts, in which you can insert headers and lines of text that include equations. However, I do not yet know of any way to dynamically construct equations to be displayed in Live Script.

Sign in to comment.

More Answers (1)

Vencel Kozma
Vencel Kozma on 23 Jan 2023
I have a workaround for that.
1. - Create a class (e.g.: "gui_status"), where you could store the correspondent text:
classdef gui_status < handle
properties
...
status_message string
end
end
2.- Create an instance inside the gui's handle like:
handles.gui_status.status_message = "";
3.- Every time you want to change the string of an "edit" object (e.g.: "edit_message"), you also store it in your new instance as well:
...
handles.gui_status.status_message = handles.edit_message.String;
...
4.- In the Callback function of "edit_message" (if you modify the text unintentionally), you could re-set it with the so-called instance:
function edit_message_Callback(hObject, eventdata, handles)
% hObject handle to edit_message (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.edit_message.String = handles.gui_status.status_message;

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!