Clear Filters
Clear Filters

Keep the variable of ediTtext if you don't change it

1 view (last 30 days)
Hello, I want to do a GUI that have 4 editText, 1 pushbutton and 1 table. I want to put the info of the editText in the table. When I put the values in the editText and I push the button, it puts in the table. If I don't change anything and I push the button, the gui don't catch the values of the editText. If I change the values all the time I don't have this problem.
  • Example: I put the values 4 5 6 7 into the text box
  • I hit the button (the values get put into the table)
  • I hit the button without changing the values (Here is my problem!)

Answers (1)

Image Analyst
Image Analyst on 2 Dec 2017
What is the code in the callback for the push button? If it extracts the edit text string, and parses it, and puts it into the table, it will work regardless if the text has been changed or not. It simply works on the current string in the edit text box.
  2 Comments
Abel Romero
Abel Romero on 2 Dec 2017
Ignore the functions, when i hit the button two times without changing the variables it does not put in the table.
function addElement_Callback(hObject, eventdata, handles)
% hObject handle to addElement (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global label value fnode lnode
[handles.E, handles.countElement]=add_Element( handles.E,handles.countElement,label,value,fnode,lnode );
[handles.c,handles.t,handles.v,handles.fn,handles.ln,handles.btn]=addInfo(handles.countElement,handles.E);
handles.datos=get(handles.uitable1, 'Data');
label=cellstr(label);
value = num2cell(value);
fnode=num2cell(fnode);
lnode=num2cell(lnode);
if isempty(handles.datos)
handles.datos(1,1)=label;
handles.datos(1,2)=value;
handles.datos(1,3)=fnode;
handles.datos(1,4)=lnode;
else
handles.datos(end+1,1)=label;
handles.datos(end,2)=value;
handles.datos(end,3)=fnode;
handles.datos(end,4)=lnode;
end
set(handles.uitable1,'Data',handles.datos);
guidata(hObject,handles);
Image Analyst
Image Analyst on 2 Dec 2017
set a breakpoint in that function. Does it step on the same lines of code in the two cases? What are the values of the variables? Just do normal debugging and you should be able to figure it out.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!