Documentation Center

  • Trial Software
  • Product Updates

setpixelposition

Set component position in pixels

Syntax

setpixelposition(handle,position)
setpixelposition(handle,position,recursive)

Description

setpixelposition(handle,position) sets the position of the component specified by handle, to the specified position relative to its parent. position is a four-element vector that specifies the location and size of the component: [pixels from left, pixels from bottom, pixels across, pixels high].

setpixelposition(handle,position,recursive) sets the position as above. If Boolean recursive is true, the position is set relative to the parent figure of handle.

Examples

This example first creates a push button within a panel.

f = figure('Position',[300 300 300 200]);
p = uipanel('Position',[.2 .2 .6 .6]);
h1 = uicontrol(p,'Style','PushButton',...
               'Units','normalized',...
               'String','Push Button',...
               'Position',[.1 .1 .5 .2]);

The example then retrieves the position of the push button and changes its position with respect to the panel.

pos1 = getpixelposition(h1);
setpixelposition(h1,pos1 + [10 10 25 25]);

See Also

| |

Was this topic helpful?