3

I have a GUI wherein I need a box which will be contain the path of a particular file. I want the text to be selectable by the user but unavailable for editing. Please help me find the answer.

Thank you in advance.

ash
  • 43
  • 4

2 Answers2

1
set(editTextHandle,'Enable','Inactive');

By doing so user can't edit the text.

Andy
  • 49,085
  • 60
  • 166
  • 233
Mazhar
  • 575
  • 5
  • 20
0

I don't know if there is a way to prevent user from editing, but you can achieve similar result by letting the callback of the edit to change the text back to its original result if user attempts to change it.

For example, you have one pushbutton that lets you choose file, and an edit text box to display filepath:

function loadfile_Callback(hObject, eventdata, handles)
[fileName, pathName] = uigetfile;
handles.fullPath = fullfile(pathName,fileName);
set(handles.edit1,'String',handles.fullPath);
guidata(hObject,handles);

function edit1_Callback(hObject, evendata, handles)
set(hObject, 'String', handles.fullPath);
guidata(hObject,handles);
user3667217
  • 2,172
  • 2
  • 17
  • 29