Figure problem: disappeared text and radio buttons in figure/questionnaire after changing fron 2012b to 2015b

1 visualización (últimos 30 días)
I wrote a small questionnaire (exemplary m-file attached) and after we updated the Matlab from 2012b to 2015b the content of this questionnaire (text, radio buttons...) disappered / is empty. No buttons or text are visible .
The code:
hFig = figure('Visible','off', 'Menu','none', 'Name','SF12', 'Resize','on',...
'units','normalized','outerposition', [0 0 1 1], 'Color', [1 1 1]);
uicontrol('Style','text','HandleVisibility','off','BackgroundColor', [1 1 0],...
'String','Headline-Text',...
'Position',[0.34 0.91 0.8 0.06],'Units','Normalized','HorizontalAlignment','left','FontSize',20,'FontName','Georgia')
%%Question 1
hBtnGrp1 = uibuttongroup('Position',[0 0.75 0.495 0.07], 'Units','Normalized','BackgroundColor', [1 1 1]);
uicontrol('Style','text','Parent',hBtnGrp1, 'HandleVisibility','off','BackgroundColor', [1 1 1],...
'String','1. This is the first question?',...
'Position',[0.02 0 0.4 0.6],'Units','Normalized','HorizontalAlignment','left','FontSize',12.5,'FontName','Georgia')
uicontrol('Style','text','Parent',hBtnGrp1, 'HandleVisibility','off',... 'String','never','HorizontalAlignment','center','BackgroundColor', [1 1 1],...
'Position',[0.42 0.6 0.15 0.29],'Units','Normalized','FontSize',12,'FontName','Georgia')
uicontrol('Style','text','Parent',hBtnGrp1, 'HandleVisibility','off',... 'String','sometimes','HorizontalAlignment','center','BackgroundColor', [1 1 1],...
'Position',[0.555 0.6 0.1 0.29],'Units','Normalized','FontSize',12,'FontName','Georgia')
uicontrol('Style','text','Parent',hBtnGrp1, 'HandleVisibility','off',... 'String','few','HorizontalAlignment','center','BackgroundColor', [1 1 1],...
'Position',[0.655 0.6 0.1 0.29],'Units','Normalized','FontSize',12,'FontName','Georgia')
uicontrol('Style','text','Parent',hBtnGrp1, 'HandleVisibility','off',... 'String','ever','HorizontalAlignment','center','BackgroundColor', [1 1 1],...
'Position',[0.755 0.6 0.1 0.29],'Units','Normalized','FontSize',12,'FontName','Georgia')
uicontrol('Style','text','Parent',hBtnGrp1, 'HandleVisibility','off',... 'String','dont know','HorizontalAlignment','center','BackgroundColor', [1 1 1],...
'Position',[0.855 0.6 0.1 0.29],'Units','Normalized','FontSize',12,'FontName','Georgia')
uicontrol('Style','Radio', 'Parent',hBtnGrp1, 'HandleVisibility','off',...
'Position',[0.5 0.3 0.1 0.2],'Units','Normalized', 'Tag','1','BackgroundColor', [1 1 1])
uicontrol('Style','Radio', 'Parent',hBtnGrp1, 'HandleVisibility','off',...
'Position',[0.6 0.3 0.1 0.2],'Units','Normalized', 'Tag','2','BackgroundColor', [1 1 1])
uicontrol('Style','Radio', 'Parent',hBtnGrp1, 'HandleVisibility','off',...
'Position',[0.7 0.3 0.1 0.2],'Units','Normalized', 'Tag','3','BackgroundColor', [1 1 1])
uicontrol('Style','Radio', 'Parent',hBtnGrp1, 'HandleVisibility','off',...
'Position',[0.8 0.3 0.1 0.2],'Units','Normalized', 'Tag','4','BackgroundColor', [1 1 1])
uicontrol('Style','Radio', 'Parent',hBtnGrp1, 'HandleVisibility','off',... 'Position',[0.9 0.3 0.1 0.2],'Units','Normalized', 'Tag','5','BackgroundColor', [1 1 1])
%%some more Qestiones...
% ...
%%Name/ID of the subject
hEdit1 = uicontrol('Style','edit', 'Position',[0.75 0.2 0.05 0.03], 'Units','Normalized','FontWeight', 'bold',... 'FontSize', 14, 'String','','FontName','Georgia','BackgroundColor', [1 1 1]);
%%the ready-button
uicontrol('Style','pushbutton', 'String','ready', 'FontSize', 14, 'FontWeight', 'bold',...
'Position',[0.70 0.1 0.1 0.05], 'Units','Normalized','Callback',{@button_callback})
set(hFig, 'Visible','on') function button_callback(~, ~)
%%Answer weight
Q1(5,1:2) = [5 , 0];
Q1(4,1:2) = [4 , 1];
Q1(3,1:2) = [3 , 2];
Q1(2,1:2) = [2 , 3];
Q1(1,1:2) = [1 , 4];
A1(1,1) = str2double(get(get(hBtnGrp1,'SelectedObject'),'Tag'));
A1Score(1,1:2) = Q1(str2double(get(get(hBtnGrp1,'SelectedObject'),'Tag')),:);
assignin('base','Answer',A1)
assignin('base','Score',A1Score)
evalin('base', [get(hEdit1, 'String') '.Answer = Answer;'])
evalin('base', [get(hEdit1, 'String') '.Score = Score;'])
end
end

Respuestas (3)

Mike Garrity
Mike Garrity el 14 de Mzo. de 2016
Starting in R2014b, the parsing of the property/value pairs in the input arguments got pickier. Your code has lots of instances of this pattern:
'Position',[0.70 0.1 0.1 0.05], 'Units','Normalized', ...
Since the properties are now parsed strictly in left-to-right order, this will do exactly what it says. That is, it will set the Position property to [.7 .1 .1 .05] in the current units (which is pixels), and then it will set the Units property to normalized. The result is a tiny uicontrol that you can't see.
Before the graphics objects became real MATLAB Objects, they had a lot of special code to catch things like this that didn't make sense and quietly fix them, but there wasn't a place to stick that code in the new system.
You'll want to switch the order of your properties around like so:
'Units','Normalized', 'Position',[0.70 0.1 0.1 0.05], ...

Julie
Julie el 11 de Mzo. de 2016
Have you tried changing the visibility of the objects. It may be set to false, especially since you create them when the parent is not visible.
set("Your Elements",'visible','on')
I tried to run your code but it did not work so I could not test it myself.

Philipp Schenk
Philipp Schenk el 15 de Mzo. de 2016
solved

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by