MATLAB Answers

LO
0

how to get value of uicontrol edit text without calling a function ?

Asked by LO
on 30 May 2019
I am trying to edit some data in real time by using a uicontrol edit box.
the box prompt me each value taken from an array (widths1), in a while loop (while i <= length(widths1)).
I would like to be able to rectify the value widths1(i) by typing in a number but somehow adding the function with the callback outside the while loop does not work.
I circumvented the problem in similar cases by adding a callback to a command in between ' ' (example 'edit = 1')
and adding an if cycle outside the uicontrol (example if edit==1, do something, end;)
however it does not seem to work in this case
ea=uicontrol('style','Edit','string',widths1(i),'Position',[510 650 50 20],'callback','editA=1');
eav=get(ea,'string')
if editA==1
widths1(i)=eav;
end
I could also try
ea=uicontrol('style','Edit','string',widths1(i),'Position',[510 650 50 20],'callback','widths1(i)=XXX');
where XXX should be the updated 'string' value of the box... but somehow using get(ea,'value') inside the command does not work becasue "ea" is not recognized as object
I am stuck..

  0 Comments

Sign in to comment.

Tags

0 Answers