For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > Simple(?!) GUI Editbox question.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Simple(?!) GUI Editbox question.
dave

2008-01-31, 8:28 pm

I have a multi-line editbox, with a scrollbar in a GUI, made
with GUIDE.

I can create new lines in the edit-box by pressing return
when I am entering data, but I don't know how to do this if
I am using the set command.

For example, at the moment I have this:
set(edit1, 'String',TheCurrentResults);

Obviously, if I run this command again with a different
variable, it will overwrite whatever is in the editbox at
the time. As this is running from within a loop, all I ever
see is the final result, which isn't very helpful.

Instead what I would like to do is make new line, and then
add the results there, keeping the previous results on the
line above.

As I see it I have two options,

1. Some how appending the next set of results to the next
line 1-by-1, without deleting what is currently there.

2. Add all the results to a long string and then do one
single set() operation at the end.


The problem is that I don't know and can't find any append
options, and also the new line (\n) command doesn't seem to
work with the second method!

Can anyone help? This is really annoying! Thanks very much!
dave

2008-01-31, 8:28 pm

Sorry for posting this twice, I pressed back and it
submitted it again.
Walter Roberson

2008-01-31, 8:28 pm

In article <fnt9ji$kdm$1@fred.mathworks.com>,
dave <davesmith@dontemailhereplease.com> wrote:
>I have a multi-line editbox, with a scrollbar in a GUI, made
>with GUIDE.


>I can create new lines in the edit-box by pressing return
>when I am entering data, but I don't know how to do this if
>I am using the set command.


>For example, at the moment I have this:
>set(edit1, 'String',TheCurrentResults);


>Obviously, if I run this command again with a different
>variable, it will overwrite whatever is in the editbox at
>the time. As this is running from within a loop, all I ever
>see is the final result, which isn't very helpful.


>Instead what I would like to do is make new line, and then
>add the results there, keeping the previous results on the
>line above.


See the matlab doc for 'uicontrol properties' and examine
the String property; the documentation on how to seperate lines
for the various kinds of controls is there. You will likely
prefer the cell array of strings.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
matt dash

2008-01-31, 8:28 pm

For example: (note which brackets are curly)

figure
u=uicontrol('units','normalized','positi
on',[.1 .1 .8 .8],...
'style','edit','horizontalalignment','le
ft','max',100);
names={'Giraffe';'Zebra';'Lion';'Rhinoce
ros';'Flamingo'};

initialstring={'Alligator'};
set(u,'string',initialstring)

pause(1)

for j=1:length(names)

mystring=get(u,'string');
mystring{end+1}=names{j};
set(u,'string',mystring)

pause(1);
end

dave

2008-01-31, 8:28 pm

Aha, you are completely correct!

I'm on my way to getting this working now, thanks very much!!
matt dash

2008-01-31, 8:28 pm

ps, note that you have to change the 'max' property for the
edit box in order to enable multi-line content.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com