---
title: "createPushButton"
canonical: "https://help.vicon.com/space/ShogunPost121/1253736992/createPushButton"
format: markdown
---
# Description

Creates a push button user control on the user window specified by windowId. A push button is a button that typically fires off an event.

The control is initially placed in the top-left corner of the user window, and must be placed by using the `-pos` option, or by using the [setControlPos](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737132) command.

The command returns the control ID of the user control, which should be saved for later operations on the control.

## Functional area

User Window

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `createPushButton parentWindowID [-hidden] [-text string] [-pos integer array] [-form integer] [-def]` |

### Arguments

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `windowId` | int | yes | ID of user window to place the control on. |

### Flags

> Macro (scroll-tablelayout)

| Name | Flag arguments | Argument type | Exclusive to | Comments |
| --- | --- | --- | --- | --- |
| `def` | 0 | — | — | Specifies that the push button is the"default" button in the user window. When the user hits the Enter key in a user window, the "default" button "push" is automatically generated. |
| `hidden` | 0 | — | — | Specifies that the control should be hidden initially. Call [showControl](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736955) to subsequently make it visible. The default is for it to be visible. |
| `text` | 1 | string | — | Specifies the text that appears on the push button. The default is no text. |
| `pos` | 1 | integer array | — | A four-element int array representing a rectangle, which specifies the initial size/position of the control relative to the top left corner of the user window. The element order is Left, Top, Right, and Bottom. |
| `form` | 1 | integer | — | Control ID of the form user control which will dynamically position this control. |

## Return value

integer

## Examples

```plaintext
// Create a Push Button User Control.
int $windowId;
int $controlId;
int $rect[4];
 
// First create a User Window to place the Control on
$windowId = `createWindow "MyWindow"`;
 
// Position the Control
$rect[0] = 20;  // Left
$rect[1] = 20;  // Top
$rect[2] = 80;  // Right
$rect[3] = 45;  // Bottom
 
// Create the Control on the Window, passing
// in the Window Id of the User Window we 
// just created. Make it the default button in the User Window
$controlId = `createPushButton $windowId -pos $rect -def -text "Push Me!"`;
```