Moving multiple boxes in figure?

前端 未结 3 1412
感情败类
感情败类 2021-01-24 04:00

I already have the functions required to drag and drop a single box in a figure in MATLAB. The code I wrote fills the figure with several boxes. With another loop I filled the f

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-24 04:24

    I usually use findall instead of findobj, in case the handles of the objects are not visible from the outside. Other than that I don't see why your code wouldn't work.

    Here's an example:

    %# make a figure with two buttons, same userData
    fh=figure,
    uicontrol('userdata',[2 3],'parent',fh)
    uicontrol('userData',[2 3],'units','normalized','position',[0.5 0.5,0.1 0.1],'parent',fh)
    
    %# change color to red
    set(findall(fh,'userData',[2 3]),'backgroundcolor','r')
    
    %# move to the same position
    set(findall(fh,'userData',[2 3]),'position',[0.3,0.3,0.1,0.1])
    

提交回复
热议问题