Dialog UI and sprintf creating unnecessary new lines
1 view (last 30 days)
I am trying to create a dialog box and set the text value inside it using the uicontrol function. The actual text I use is a combination of 3 different string variables that I combine using sprintf.
ui_message = sprintf('%s\n%s\n%s',line_1,line_2,line_3)
However, in cases where line_2 is a string that is longer than the dialog box itself, it moves down onto the next line (which is desirable) but it also adds a new line between line_1 and line_2!
So where I want my results to appear in the ui dialog box as (self explanatory what corresponds to which "line_N" variable"):
For some reason I get
instead. If the AAAAA string overlaps two lines, then there are two spaces between the first and second lines.
Binbin Qi on 18 Aug 2020
The following is my code. It is can work normally. Can you give your code here?
if nargin == 0
line1 = 'Hello';
line2 = 'AAAAAAAAAAAAA';
line3 = 'Goodbye';
ui_message = @(line_1,line_2,line_3)sprintf('%s\n%s\n%s',line_1,line_2,line_3);
d = dialog('Position',[300 300 250 150],'Name','My Dialog');
'Position',[20 80 210 40],...
'Position',[85 20 70 25],...