用uipanel盖住uicontrol

时间:2018-05-08 13:22:14

标签: matlab matlab-figure uicontrol

在Matlab R2014a中,我想创建一个uicontrol部分涵盖的uipanel

如果我运行以下功能:

function test()
h = figure;
set(h, 'Position', [100, 100, 500, 300]);
mainPanel = uipanel(                     ...
  'Parent'         , h                 , ...
  'Units'          , 'pixels'          , ...
  'Position'       , [10, 10, 300, 500], ...
  'BackgroundColor', [0.6, 0.6, 0.6]     ...
  );
uicontrol(                        ...
  'Parent'  , mainPanel         , ...
  'Units'   , 'pixels'          , ...
  'Style'   , 'popupmenu'       , ...
  'String'  , {'S1', 'S2', 'S3'}, ...
  'Position', [100, 200, 200, 20] ...
  );
topPanel = uipanel(                        ...
  'Parent'         , mainPanel           , ...
  'Units'          , 'pixels'            , ...
  'Position'       , [150, 160, 100, 100], ...
  'BackgroundColor', [0.9, 0.2, 0.1]       ...
  );
end

我得到了下图:

Example

即使我在uicontrol和同一父母之后绘制红色面板,它也不会覆盖控件。

相反,我想绘制一个涵盖所有现有图形的面板。我想要获得的结果如下:

enter image description here

如何创建一个覆盖图中显示的现有控件(和其他面板)的面板?

当然这只是一个用于显示问题的测试功能,我真正的问题更复杂,并且与创建可滚动面板有关......

0 个答案:

没有答案