<div class="meta" robots="noindex">

</div>

Class

# SegmentedButton (deprecated)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r3. Please use `DesktopSegmentedButton</api/user_interface/desktop/desktopsegmentedbutton>` as a replacement.

</div>

## Description

A control that is a horizontal button made up of multiple, independent segments.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                         | Type                                                   | Read-Only | Shared |
|--------------------------------------------------------------|--------------------------------------------------------|-----------|--------|
| `Active<segmentedbutton.active>`                             | `Boolean</api/data_types/boolean>`                     | ✓         |        |
| `AllowAutoDeactivate<segmentedbutton.allowautodeactivate>`   | `Boolean</api/data_types/boolean>`                     |           |        |
| `AllowTabStop<segmentedbutton.allowtabstop>`                 | `Boolean</api/data_types/boolean>`                     |           |        |
| `Enabled<segmentedbutton.enabled>`                           | `Boolean</api/data_types/boolean>`                     |           |        |
| `Handle<segmentedbutton.handle>`                             | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Height<segmentedbutton.height>`                             | `Integer</api/data_types/integer>`                     |           |        |
| `Index<segmentedbutton.index>`                               | `Integer</api/data_types/integer>`                     | ✓         |        |
| `LastSegmentIndex<segmentedbutton.lastsegmentindex>`         | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Left<segmentedbutton.left>`                                 | `Integer</api/data_types/integer>`                     |           |        |
| `LockBottom<segmentedbutton.lockbottom>`                     | `Boolean</api/data_types/boolean>`                     |           |        |
| `LockLeft<segmentedbutton.lockleft>`                         | `Boolean</api/data_types/boolean>`                     |           |        |
| `LockRight<segmentedbutton.lockright>`                       | `Boolean</api/data_types/boolean>`                     |           |        |
| `LockTop<segmentedbutton.locktop>`                           | `Boolean</api/data_types/boolean>`                     |           |        |
| `MacButtonStyle<segmentedbutton.macbuttonstyle>`             | `Integer</api/data_types/integer>`                     |           |        |
| `MouseCursor<segmentedbutton.mousecursor>`                   | `MouseCursor</api/user_interface/desktop/mousecursor>` |           |        |
| `MouseX<segmentedbutton.mousex>`                             | `Integer</api/data_types/integer>`                     | ✓         |        |
| `MouseY<segmentedbutton.mousey>`                             | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Name<segmentedbutton.name>`                                 | `String</api/data_types/string>`                       | ✓         |        |
| `PanelIndex<segmentedbutton.panelindex>`                     | `Integer</api/data_types/integer>`                     |           |        |
| `Parent<segmentedbutton.parent>`                             | `Control</api/deprecated/control>`                     |           |        |
| `Scope<segmentedbutton.scope>`                               | `Integer</api/data_types/integer>`                     | ✓         |        |
| `SegmentCount<segmentedbutton.segmentcount>`                 | `Integer</api/data_types/integer>`                     | ✓         |        |
| `Segments<segmentedbutton.segments>`                         | Segment(                                               |           |        |
| `SelectedSegment<segmentedbutton.selectedsegment>`           | `Segment</api/user_interface/desktop/segment>`         | ✓         |        |
| `SelectedSegmentIndex<segmentedbutton.selectedsegmentindex>` | `Integer</api/data_types/integer>`                     |           |        |
| `SelectionStyle<segmentedbutton.selectionstyle>`             | `SelectionStyles<segmentedbutton.selectionstyles>`     |           |        |
| `TabIndex<segmentedbutton.tabindex>`                         | `Integer</api/data_types/integer>`                     |           |        |
| `Tooltip<segmentedbutton.tooltip>`                           | `String</api/data_types/string>`                       |           |        |
| `Top<segmentedbutton.top>`                                   | `Integer</api/data_types/integer>`                     |           |        |
| `Transparent<segmentedbutton.transparent>`                   | `Boolean</api/data_types/boolean>`                     |           |        |
| `TrueWindow<segmentedbutton.truewindow>`                     | `Window</api/deprecated/window>`                       | ✓         |        |
| `Visible<segmentedbutton.visible>`                           | `Boolean</api/data_types/boolean>`                     |           |        |
| `Width<segmentedbutton.width>`                               | `Integer</api/data_types/integer>`                     |           |        |
| `Window<segmentedbutton.window>`                             | `Window</api/deprecated/window>`                       | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                       | Parameters                                                                                                                | Returns                                        | Shared |
|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|--------|
| `AcceptFileDrop<segmentedbutton.acceptfiledrop>`           | FileType As `String</api/data_types/string>`                                                                              |                                                |        |
| `AcceptPictureDrop<segmentedbutton.acceptpicturedrop>`     |                                                                                                                           |                                                |        |
| `AcceptRawDataDrop<segmentedbutton.acceptrawdatadrop>`     | Type As `String</api/data_types/string>`                                                                                  |                                                |        |
| `AcceptTextDrop<segmentedbutton.accepttextdrop>`           |                                                                                                                           |                                                |        |
| `AddSegment<segmentedbutton.addsegment>`                   | segment As `Segment</api/user_interface/desktop/segment>`                                                                 |                                                |        |
| `AddSegmentAt<segmentedbutton.addsegmentat>`               | index As `Integer</api/data_types/integer>`, segment As `Segment</api/user_interface/desktop/segment>`                    |                                                |        |
| `Close<segmentedbutton.close_method>`                      |                                                                                                                           |                                                |        |
| `DrawInto<segmentedbutton.drawinto>`                       | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>` |                                                |        |
| `Invalidate<segmentedbutton.invalidate>`                   | \[EraseBackground As `Boolean</api/data_types/boolean>`\]                                                                 |                                                |        |
| `Refresh<segmentedbutton.refresh>`                         | eraseBackground As `Boolean</api/data_types/boolean>`                                                                     |                                                |        |
| `RemoveAllSegments<segmentedbutton.removeallsegments>`     |                                                                                                                           |                                                |        |
| `RemoveSegmentAt<segmentedbutton.removesegmentat>`         | index As `Integer</api/data_types/integer>`                                                                               |                                                |        |
| `ResizeSegmentsToFit<segmentedbutton.resizesegmentstofit>` |                                                                                                                           |                                                |        |
| `SegmentAt<segmentedbutton.segmentat>`                     | index As `Integer</api/data_types/integer>`                                                                               | `Segment</api/user_interface/desktop/segment>` |        |
| `SetFocus<segmentedbutton.setfocus>`                       |                                                                                                                           |                                                |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                               | Parameters                                                                                                                                                                              | Returns                            |
|--------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `Close<segmentedbutton.close_event>`                               |                                                                                                                                                                                         |                                    |
| `ConstructContextualMenu<segmentedbutton.constructcontextualmenu>` | Base As `MenuItem</api/deprecated/menuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                          | `Boolean</api/data_types/boolean>` |
| `ContextualMenuAction<segmentedbutton.contextualmenuaction>`       | HitItem As `MenuItem</api/deprecated/menuitem>`                                                                                                                                         | `Boolean</api/data_types/boolean>` |
| `DragEnter<segmentedbutton.dragenter>`                             | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                   | `Boolean</api/data_types/boolean>` |
| `DragExit<segmentedbutton.dragexit>`                               | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`                                                                                   |                                    |
| `DragOver<segmentedbutton.dragover>`                               | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>` | `Boolean</api/data_types/boolean>` |
| `DropObject<segmentedbutton.dropobject>`                           | Obj As `DragItem</api/user_interface/desktop/dragitem>` Action As `Integer</api/data_types/integer>`                                                                                    |                                    |
| `KeyDown<segmentedbutton.keydown>`                                 | Key As `String</api/data_types/string>`                                                                                                                                                 | `Boolean</api/data_types/boolean>` |
| `KeyUp<segmentedbutton.keyup>`                                     | Key As `String</api/data_types/string>`                                                                                                                                                 |                                    |
| `MouseEnter<segmentedbutton.mouseenter>`                           |                                                                                                                                                                                         |                                    |
| `MouseExit<segmentedbutton.mouseexit>`                             |                                                                                                                                                                                         |                                    |
| `MouseMove<segmentedbutton.mousemove>`                             | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                        |                                    |
| `MouseWheel<segmentedbutton.mousewheel>`                           | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`            | `Boolean</api/data_types/boolean>` |
| `Open<segmentedbutton.open>`                                       |                                                                                                                                                                                         |                                    |
| `Pressed<segmentedbutton.pressed>`                                 | segmentIndex As Integer                                                                                                                                                                 |                                    |

## Enumerations

<div id="segmentedbutton.macbuttonstyles">

<div class="rst-class">

forsearch

</div>

</div>

SegmentedButton.MacButtonStyles

### MacButtonStyles

Specifies the various segmented button styles when the control is displayed on macOS.

| Style           |
|-----------------|
| Automatic       |
| Capsule         |
| RoundRectangle  |
| Rounded         |
| TexturedRounded |
| TexturedSquare  |
| SmallSquare     |

<div id="segmentedbutton.selectionstyles">

<div class="rst-class">

forsearch

</div>

</div>

SegmentedButton.SelectionStyles

### SelectionStyles

Specifies how many buttons can be selected at a time.

| Enum     | Description                                                                   |
|----------|-------------------------------------------------------------------------------|
| Single   | Like a group of radio buttons, only one segment can be selected at a time.    |
| Multiple | Like a group of checkboxes, any number of segments can be selected at a time. |
| None     | Like a series of pushbuttons, no segment can remained selected once pressed.  |

## Property descriptions

<div id="segmentedbutton.active">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Active

**Active** As `Boolean</api/data_types/boolean>`

Indicates whether the `RectControl</api/deprecated/rectcontrol>` is active.

This property is read-only.

Active is `False</api/language/false>` when the `RectControl</api/deprecated/rectcontrol>`'s window is not in the foreground. When a `Window</api/deprecated/window>` is deactivated, its controls are automatically deactivated unless `AutoDeactivate<rectcontrol.allowautodeactivate>` is set to `False</api/language/false>`.

<div id="segmentedbutton.allowautodeactivate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AllowAutoDeactivate

**AllowAutoDeactivate** As `Boolean</api/data_types/boolean>`

Determines whether the control should be deactivated (on macOS) when the parent window is deactivated. The default is `True</api/language/true>`.

<div id="segmentedbutton.allowtabstop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AllowTabStop

**AllowTabStop** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, the **RectControl** is in the Tab Order and accepts the focus when the user tabs into it. The default is `True</api/language/true>`. If `False</api/language/false>`, the user cannot tab into it to give it the focus. However, the **RectControl** can gain the focus by other means, such as the user's clicking on it or by setting the focus in code.

This example removes the control from the Tab Order:

``` xojo
Me.AllowTabStop = False
```

<div id="segmentedbutton.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

Determines if the control should be enabled when the owning window is opened.

A disabled control cannot be clicked and cannot receive the focus.

This example disables the control. Its caption is grayed out.

``` xojo
Me.Enabled = False
```

<div id="segmentedbutton.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Handle

**Handle** As `Integer</api/data_types/integer>`

Returns a handle to the control.

This property is read-only.

For interfacing with Mac APIs using `` Declare</api/language/declare>`s, RectControl.Handle returns NSViews (except for :doc:`Toolbar</api/deprecated/toolbar> ``).

On Windows returns the HWND of the control.

On Linux it returns a GtkWidget.

The following gets a handle to the control.

``` xojo
Var i As Integer = Me.Handle
```

<div id="segmentedbutton.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Height

**Height** As `Integer</api/data_types/integer>`

The height (in points) of the control.

This example sets the height of the control to 100:

``` xojo
Me.Height = 100
```

<div id="segmentedbutton.index">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Index

**Index** As `Integer</api/data_types/integer>`

If the control is used in a control set, this specifies the control's index in the set.

This property is read-only.

The *control set* is often used to manage a group of RadioButtons since a single RadioButton in a window doesn't make much sense. Most typically, you create an instance of the RadioButton, assign 0 to its Index property, and then duplicate it. This increments the value of Index for each new instance but retain the original control's name.

To determine which RadioButton the user clicked, use the Action event handler of the control set. The parameter *Index* contains the value of Index for the RadioButton that was clicked. The event handler is this:

``` xojo
Sub Action(Index As Integer)
  Label1.Text = "You chose radio button " + index.ToString + "."
End Sub
```

To set a RadioButton in a control set, you use its *Index* property to refer to the RadioButton whose value you want to set. For example, the following line selects the second RadioButton from code:

``` xojo
RadioButton1(1).Value = True ' 0-based
```

<div id="segmentedbutton.lastsegmentindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.LastSegmentIndex

**LastSegmentIndex** As `Integer</api/data_types/integer>`

The number of the last `Segment</api/user_interface/desktop/segment>` of the <span class="title-ref">SegmentedButton</span>.

This property is read-only.

<div id="segmentedbutton.left">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Left

**Left** As `Integer</api/data_types/integer>`

The left side of the control in local coordinates (relative to the window).

The following example moves the control 100 points from the left side of the window:

``` xojo
Me.Left = 150
```

<div id="segmentedbutton.lockbottom">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.LockBottom

**LockBottom** As `Boolean</api/data_types/boolean>`

Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning window.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockBottom = True
```

<div id="segmentedbutton.lockleft">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.LockLeft

**LockLeft** As `Boolean</api/data_types/boolean>`

Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning window.

Beginning with version 2009r5, LockLeft and Locktop default to `True</api/language/true>` when you add a new control to a window. Existing controls will be altered only if LockRight and/or LockBottom are not set. *LockLeft* has no effect unless *LockRight* is `True</api/language/true>`.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockLeft = True
```

<div id="segmentedbutton.lockright">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.LockRight

**LockRight** As `Boolean</api/data_types/boolean>`

Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning window.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockRight = True
```

<div id="segmentedbutton.locktop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.LockTop

**LockTop** As `Boolean</api/data_types/boolean>`

Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning window.

Beginning with version 2009r5, LockTop and LockLeft default to `True</api/language/true>` when you add a control to a window. Existing controls will be altered only if LockRight and/or LockBottom are not set. *LockTop* has no effect unless *LockBottom* is `True</api/language/true>`.

This property can be set in the control's Inspector. The following example sets it in code.

``` xojo
Me.LockTop = True
```

<div id="segmentedbutton.macbuttonstyle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MacButtonStyle

**MacButtonStyle** As `Integer</api/data_types/integer>`

Controls the appearance of the <span class="title-ref">SegmentedButton</span> on macOS.

Use `MacButtonStyles<segmentedbutton.macbuttonstyles>` to set/get this property.

Not all button styles are available on all versions of macOS.

> ![image](images/segmentedbutton_automatic2.png)
>
> ![image](images/segmentedbutton_capsule2.png)
>
> ![image](images/segmentedbutton_round_rectangle2.png)
>
> ![image](images/segmentedbutton_rounded2.png)
>
> ![image](images/segmentedbutton_textured_rounded2.png)
>
> ![image](images/segmentedbutton_textured_square2.png)
>
> ![image](images/segmentedbutton_small_square2.png)

This code is in the Initialized event of the control but will only take effect when building for macOS. It sets the style to Rounded.

``` xojo
Me.MacButtonStyle = SegmentedButton.MacButtonStyles.Rounded
```

<div id="segmentedbutton.mousecursor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseCursor

**MouseCursor** As `MouseCursor</api/user_interface/desktop/mousecursor>`

The cursor to be displayed while the mouse is within the control and both the `DesktopApplication</api/user_interface/desktop/desktopapplication>` and `Window</api/deprecated/window>` class's MouseCursor properties are `Nil</api/language/nil>`.

If the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's MouseCursor property is not `Nil</api/language/nil>` or the `Window</api/deprecated/window>`'s MouseCursor property is not `Nil</api/language/nil>`, then any control's MouseCursor property is ignored. You can use a cursor stored in the `Cursors</api/user_interface/desktop/cursors>` module. On Macintosh, you can also obtain a `MouseCursor</api/user_interface/desktop/mousecursor>` from a resource file.

This line in the Opening event of the control sets the default cursor to the finger pointer.

``` xojo
Me.MouseCursor = System.Cursors.FingerPointer
```

<div id="segmentedbutton.mousex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseX

**MouseX** As `Integer</api/data_types/integer>`

The X coordinate of the mouse (points). Measured from the top-left corner of the control.

This property is read-only.

This code is in the MouseDown event of a `TextField</api/deprecated/textfield>` and displays the X-coordinate at the point of the MouseDown event.

``` xojo
Me.Value = Str(Me.MouseX)
```

<div id="segmentedbutton.mousey">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseY

**MouseY** As `Integer</api/data_types/integer>`

The Y coordinate of the mouse (points). Measured from the top-left corner of the control.

This property is read-only.

This code is in the MouseDown event of a `TextField</api/deprecated/textfield>` and displays the Y-coordinate at the point of the MouseDown event.

``` xojo
Me.Value = Str(Me.MouseY)
```

<div id="segmentedbutton.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Name

**Name** As `String</api/data_types/string>`

The name of the control. Set the name of the control in the Inspector.

This property is read-only.

<div id="segmentedbutton.panelindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.PanelIndex

**PanelIndex** As `Integer</api/data_types/integer>`

If the control has been placed on a `TabPanel</api/deprecated/tabpanel>` or `PagePanel</api/deprecated/pagepanel>` control, this is the panel (page/tab) that the control is on. If the control is not on a panel, it returns -1.

The first panel is numbered zero. If the control has been placed on a panel of a `TabPanel</api/deprecated/tabpanel>` or `PagePanel</api/deprecated/pagepanel>` control, it returns the panel number. If the control is not on a `PagePanel</api/deprecated/pagepanel>` or `TabPanel</api/deprecated/tabpanel>`, it returns -1. If you change the PanelIndex to a nonexistent panel, the control will disappear until you give it a PanelIndex value that corresponds to a panel that exists.

If you are looking to change the currently selected panel (page/tab), use `PagePanel<pagepanel.selectedpanelindex>`.

This code displays the panel index of the control that is on the page.

``` xojo
Label3.Value = Str(Me.PanelIndex)
```

<div id="segmentedbutton.parent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Parent

**Parent** As `Control</api/deprecated/control>`

Used to get and set the control's parent control or window.

Returns `Nil</api/language/nil>` if the parent is the window. Assign `Nil</api/language/nil>` to make the control's parent the window, even if it is enclosed by another control. The child control's behavior in the IDE will reflect the parent's state. If the parent control is somehow in another window, an `InvalidParentException</api/exceptions/invalidparentexception>` will occur.

The following example sets the parent of the control to the window.

``` xojo
Me.Parent = Nil
```

<div id="segmentedbutton.scope">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Scope

**Scope** As `Integer</api/data_types/integer>`

Used to determine whether access to the control is Public (0) or Private (2). The default is Public.

This property is read-only.

If the Scope of a control is set to Private, it cannot be accessed from outside its parent window.

<div id="segmentedbutton.segmentcount">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.SegmentCount

**SegmentCount** As `Integer</api/data_types/integer>`

The number of `` Segment</api/user_interface/desktop/segment>`s in the `SegmentedButton ``.

This property is read-only.

This example displays the number of `` Segment</api/user_interface/desktop/segment>`s in the `SegmentedButton ``.

``` xojo
MsgBox(SegmentedButton1.SegmentCount.ToString)
```

<div id="segmentedbutton.segments">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Segments

**Segments** As Segment(

Segments is a Design-Time property that is used to created and edit individual segments.

Click the Edit button next to Segments in the Inspector to display the <span class="title-ref">SegmentedButton</span> Editor which you can use to add, remove, reorder, or edit segments. Use the Select checkbox to choose the segment that will be selected by default. In the illustration below, the second segment is selected by default. You can rename a segment by clicking twice on an existing segment to make it editable.

<div id="segmentedbutton.selectedsegment">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.SelectedSegment

**SelectedSegment** As `Segment</api/user_interface/desktop/segment>`

Provides the `Segment</api/user_interface/desktop/segment>` at the requested index.

This property is read-only.

For multi-selection SegmentedButtons this returns the last segment that was selected.

<div id="segmentedbutton.selectedsegmentindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.SelectedSegmentIndex

**SelectedSegmentIndex** As `Integer</api/data_types/integer>`

Used to get or set the selected segment number. The first segment is numbered zero.

A value of -1 means no selection. SelectedSegmentIndex may be set using the Properties pane to set the default value of the <span class="title-ref">SegmentedButton</span> control. SelectedSegmentIndex is only useful when `SelectionStyle<segmentedbutton.selectionstyle>` is set to Single. `SelectedSegment<segmentedbutton.selectedsegment>` will provide you with the `Segment</api/user_interface/desktop/segment>` for the selected segment.

For multi-selection SegmentedButtons this returns the last segment that was selected.

If `SelectionStyle<segmentedbutton.selectionstyle>` is set to Multiple, you must use `SegmentAt<segmentedbutton.segmentat>` to check each segment's `Selected<segment.selected>` property to see if it's True or not.

The following example changes the selected segment to the third segment:

``` xojo
SegmentedButton1.SelectedSegmentIndex = 2
```

<div id="segmentedbutton.selectionstyle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.SelectionStyle

**SelectionStyle** As `SelectionStyles<segmentedbutton.selectionstyles>`

The style of selection for the control. The options are Single, Multiple or None. See `SelectionStyles<segmentedbutton.selectionstyles>` for details.

<div id="segmentedbutton.tabindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.TabIndex

**TabIndex** As `Integer</api/data_types/integer>`

The **RectControl's** position in the Tab Order. It is 0-based. A TabIndex of 0 is the first **RectControl** to get the focus.

On the Mac you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.

This example sets the control's TabIndex.

``` xojo
Me.TabIndex = 2
```

<div id="segmentedbutton.tooltip">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Tooltip

**Tooltip** As `String</api/data_types/string>`

Text of help message displayed as a Windows or Linux "tooltip" or macOS help tag.

The tip/tag is displayed when the user hovers the mouse cursor over the control.

This example adds a tooltip to a `BevelButton</api/deprecated/bevelbutton>` that has an icon.

``` xojo
Me.CaptionAlignment = 0 ' left
Me.CaptionDelta = 10
Me.Tooltip = "Click to bark."

Me.Icon = Woof ' added to the project
Me.CaptionPosition = 2
```

<div id="segmentedbutton.top">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Top

**Top** As `Integer</api/data_types/integer>`

The top of the control in local coordinates (relative to the window).

This example sets the top of the control to 140 points from the top of the window:

``` xojo
Me.Top = 140
```

<div id="segmentedbutton.transparent">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Transparent

**Transparent** As `Boolean</api/data_types/boolean>`

Determines whether the control is transparent on Windows. The default is `False</api/language/false>`. Has no effect on macOS or Linux.

Transparent controls draw more slowly and use more memory in order to cache the background. Unless you absolutely require transparency, leave this set to False.

For projects that were created prior to 2018r1, this property defaults to True to emulate previous behavior. Consider changing it to False to improve performance if you do not require transparency.

<div id="segmentedbutton.truewindow">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.TrueWindow

**TrueWindow** As `Window</api/deprecated/window>`

Returns a reference to the actual enclosing `Window</api/deprecated/window>`.

This property is read-only.

TrueWindow walks up the window hierarchy and finds the actual enclosing window regardless of how deeply nested the `RectControl</api/deprecated/rectcontrol>` or `DesktopContainer</api/user_interface/desktop/desktopcontainer>` hierarchy is.

`Window</api/deprecated/window>` also has a TrueWindow property.

This example accesses the TrueWindow and displays its Title property in a `TextField</api/deprecated/textfield>`.

``` xojo
TextField1.Text = Me.TrueWindow.Title
```

<div id="segmentedbutton.visible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Visible

**Visible** As `Boolean</api/data_types/boolean>`

Determines whether the control is visible when its owning window is opened. The default is `True</api/language/true>`: the control is visible.

The following code in the DisclosureTriangle Action event handler displays or hides a ListBox on the window:

``` xojo
ListBox1.Value = Me.Visible
```

<div id="segmentedbutton.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Width

**Width** As `Integer</api/data_types/integer>`

The width (in points) of the control.

The following example resizes the control:

``` xojo
Me.Width = 200
```

<div id="segmentedbutton.window">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Window

**Window** As `Window</api/deprecated/window>`

The control's parent window.

This property is read-only.

This code gets the parent window's Title property.

``` xojo
TextField1.Text = Me.Window.Title
```

## Method descriptions

<div id="segmentedbutton.acceptfiledrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AcceptFileDrop

**AcceptFileDrop**(FileType As `String</api/data_types/string>`)

Permits documents of type *FileType* to be dropped on the control. *FileType* must be a file type that you defined in via the `FileType</api/files/filetype>` class or the File Type Sets Editor.

This code in the Opening event of an `ImageWell</api/deprecated/imagewell>` makes it possible for the user to drop either a picture or a file that is a jpeg image. The File Type Sets editor was used to define the “image/jpeg” file type. It is one of the “Common File Types” that is available in the editor.

``` xojo
Me.AcceptPictureDrop
Me.AcceptFileDrop("image/jpeg")
```

To restrict file drops to just folders (and not files), you can put this code in the `DragEnter<rectcontrol.dragenter>` event:

``` xojo
If Not obj.FolderItem.IsFolder Then Return True
```

<div id="segmentedbutton.acceptpicturedrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AcceptPictureDrop

**AcceptPictureDrop**

Permits pictures to be dropped on the control.

If a control should accept pictures in a drag and drop, then AcceptPictureDrop needs to be called prior to the drop. Typically, it is in the Opening event of the control itself. For example, the line:

``` xojo
Me.AcceptPictureDrop
```

in the Opening event of the control that will receive the dragged pictures is needed. When the picture is dropped, the `DropObject<rectcontrol.dropobject>` event is called and this is where you will put your code to handle the drop.

Canvas.Open:

``` xojo
Me.AcceptPictureDrop
```

Canvas.DropObject:

``` xojo
If obj.PictureAvailable Then
  Me.Backdrop = obj.Picture
End If
```

<div id="segmentedbutton.acceptrawdatadrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AcceptRawDataDrop

**AcceptRawDataDrop**(Type As `String</api/data_types/string>`)

Permits data (of the Type specified) to be dropped on the control.

The following specfies a generic file type defined in the File Type Sets editor.

``` xojo
Me.AcceptRawDataDrop("????")
```

<div id="segmentedbutton.accepttextdrop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AcceptTextDrop

**AcceptTextDrop**

Permits text to be dropped on the control.

This line in the opening event of a control that can accept dragged text.

``` xojo
Me.AcceptTextDrop
```

<div id="segmentedbutton.addsegment">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AddSegment

**AddSegment**(segment As `Segment</api/user_interface/desktop/segment>`)

Adds *Segment* as a new segment at the end of the control.

The following example in the `Open<control.open>` event of the control adds a segment to it:

``` xojo
Var seg As New Segment
seg.Title = "Banana"
Me.AddSegment(seg)
```

<div id="segmentedbutton.addsegmentat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.AddSegmentAt

**AddSegmentAt**(index As `Integer</api/data_types/integer>`, segment As `Segment</api/user_interface/desktop/segment>`)

Creates a new segment at *index* (moving the existing segments over).

The following example adds a segment at the 4th position.

``` xojo
Var s As New Segment
s.Title = "Harry"
SegmentedButton1.AddSegmentAt(3, s)
```

<div id="segmentedbutton.close_method">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Close

**Close**

Closes a control.

Closing a control permanently removes the control from memory, making it impossible to access. You can close both non-indexed controls and indexed controls. When you close an indexed control, the indexes for the remaining controls will shift downward so that the indexes start with zero and are consecutive.

The following code closes the control. When this is executed from a visible control, the control disappears from the window.

``` xojo
Me.Close
```

<div id="segmentedbutton.drawinto">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.DrawInto

**DrawInto**(g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`)

Draws the contents of the RectControl into the specified `Graphics</api/graphics/graphics>` context. The parameters *x* and *y* are the coordinates of the top, left corner.

This method does not work with `HTMLViewer</api/deprecated/htmlviewer>` and `OpenGLSurface</api/deprecated/openglsurface>`.

This example draws the current control into the Graphics of a Picture and then displays it as the Backdrop of a Canvas:

``` xojo
Var p As New Picture(Me.Width, Me.Height)
Me.DrawInto(p.Graphics, 0, 0)
Canvas1.Backdrop = p
```

<div id="segmentedbutton.invalidate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Invalidate

**Invalidate**(\[EraseBackground As `Boolean</api/data_types/boolean>`\])

Similar to RefreshRect, but causes the specified region of the RectControl to be marked dirty and to be redrawn when the window contents need to be redrawn. The region to be redrawn is specified by the *X*, *Y*, *Width*, and *Height* parameters. This form of Invalidate was formerly called InvalidateRect.

The following code refreshes the control. EraseBackground defaults to `True</api/language/true>`.

``` xojo
Me.Invalidate(False)
```

<div id="segmentedbutton.refresh">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Refresh

**Refresh**(eraseBackground As `Boolean</api/data_types/boolean>`)

Repaints the portion specified of the contents of the control immediately.

Calling this frequently can cause the code executing to slow down. It is often preferable to call `RectControl<rectcontrol.invalidate>` instead.

Refresh the entire area:

``` xojo
Me.Refresh(False)
```

Refresh a portion of the area:

``` xojo
Me.Refresh(100, 150, 200, 300)
```

<div id="segmentedbutton.removeallsegments">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.RemoveAllSegments

**RemoveAllSegments**

Removes all segments in the control.

The following example (in any event of a <span class="title-ref">SegmentedButton</span> removes all the existing segments:

``` xojo
Me.RemoveAllSegments
```

<div id="segmentedbutton.removesegmentat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.RemoveSegmentAt

**RemoveSegmentAt**(index As `Integer</api/data_types/integer>`)

Removes the specified segment. The first segment is numbered zero.

When in any event of a segmented control, the following example removes the third segment (index position 2) from the segmented control:

``` xojo
Me.RemoveSegmentAt(2)
```

<div id="segmentedbutton.resizesegmentstofit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.ResizeSegmentsToFit

**ResizeSegmentsToFit**

Sizes the control to fit into its space, increasing or decreasing its width as necessary. Use this after making changes to the `Segment</api/user_interface/desktop/segment>` width.

If you add a new segment, the <span class="title-ref">SegmentedButton</span> does not resize to fit it so you need to call ResizeSegmentsToFit:

``` xojo
' Add a new segment
Var seg As New Segment
seg.Title = "Seg " + Str(SegmentedButton1.LastSegmentIndex + 1)
SegmentedButton1.AddSegment(seg)

SegmentedButton1.ResizeSegmentsToFit
```

If you need to keep the <span class="title-ref">SegmentedButton</span> width the same then you will want to resize the individual segments to fit within the <span class="title-ref">SegmentedButton</span> width. This example shows how to do that:

``` xojo
Var seg As New Segment
seg.Title = "Seg " + Str(SegmentedButton1.LastSegmentIndex + 1)

SegmentedButton1.AddSegment(seg)

' Resize all the segments
For i As Integer = 0 To SegmentedButton1.LastSegmentIndex
  Var item As Segment = SegmentedButton1.SegmentAt(i)
  item.Width = SegmentedButton1.Width / (SegmentedButton1.LastSegmentIndex + 1) - 2
Next
```

This example demonstrates how to dynamically change a <span class="title-ref">SegmentedButton</span>'s properties on the fly. For example, this code on a `PushButton</api/deprecated/pushbutton>` increases the size of the selected segment. The code cycles through all the segments and increases the size of each segment that is selected. The loop creates an instance of a `Segment</api/user_interface/desktop/segment>` for each segment, tests whether it is selected using the `Selected<segment.selected>` property, and then increases the width for only the selected ones. This will increase the overall width of the SegmentedControl:

``` xojo
' count down to avoid re-evaluating the Ubound all the time
For i As Integer = SegmentedButton1.LastSegmentIndex DownTo 0

  ' get the reference to the segment
  Var s As Segment = SegmentedButton1.SegmentAt(i)

  ' see if the segment was selected
  If s.Selected Then
    ' it is selected so increase this segment in size
    s.Width = s.Width + 10
  End If
Next

' make sure the segmented control knows to resizes its drawing boundaries or you can get weird effects
SegmentedButton1.ResizeSegmentsToFit
```

<div id="segmentedbutton.segmentat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.SegmentAt

**SegmentAt**(index As `Integer</api/data_types/integer>`) As `Segment</api/user_interface/desktop/segment>`

Returns the `Segment</api/user_interface/desktop/segment>` instance at the index requested.

Use this property to change the properties of each `Segment</api/user_interface/desktop/segment>` in the <span class="title-ref">SegmentedButton</span>.

This code loops through all the segments and changes their Titles:

``` xojo
Var seg As Segment
For position As Integer = 0 To SegmentedButton1.LastSegmentIndex
  seg = SegmentedButton1.SegmentAt(position)
  seg.Title = position.ToString
Next
```

This code adds a new segment and then resizes all the segments so that they are visible:

``` xojo
Var seg As New Segment
seg.Title = "Seg " + Str(SegmentedButton1.SegmentCount)

SegmentedButton1.AddSegment(seg)

' Resize all the segments
For i As Integer = 0 To SegmentedButton1.LastSegmentIndex
  Var item As Segment = SegmentedButton1.SegmentAt(i)
  item.Width = SegmentedButton1.Width / (SegmentedButton1.SegmentCount) - 2
Next
```

<div id="segmentedbutton.setfocus">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.SetFocus

**SetFocus**

If applicable, sets the focus to the RectControl. KeyDown events are directed to the control.

If the control cannot get the focus on the platform on which the application is running, SetFocus does nothing. The SetFocus method of the `Window</api/deprecated/window>` class or the `ClearFocus</api/user_interface/desktop/clearfocus>` method can be used to remove the focus from the control that currently has the focus, leaving no control with the focus.

On the Mac you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.

The following example sets the focus to TextField1. If another control has the focus when this line is executed, then the user sees that TextField1 gets the focus.

``` xojo
TextField1.SetFocus
```

## Event descriptions

<div id="segmentedbutton.close_event">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Close

**Close**

The control is about to close.

<div id="segmentedbutton.constructcontextualmenu">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.ConstructContextualMenu

**ConstructContextualMenu**(Base As `MenuItem</api/deprecated/menuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

This event is called when it is appropriate to display a contextual menu for the control.

This event handler is the recommended way to handle contextual menus because this event figures out whether the user has requested the contextual menu, regardless of how they did it. Depending on platform, it might be in the MouseUp or MouseDown event and it might be a right+click or by pressing the contextual menu key on the keyboard, for example.

*Base* is analogous to the menu bar for the contextual menu. Any items you add to *Base* will be shown as menu items. If you return `False</api/language/false>`, the event is passed up the parent hierarchy.

If you return `True</api/language/true>`, the contextual menu is displayed. The parameters *x* and *y* are the mouse locations. If the event was fired because of a non-mouse event, then *x* and *y* are both set to -1. See the example of a contextual menu in the following section.

The following ConstructContextualMenu event handler builds a menu with three menu items plus a submenu with three additional menu items.

``` xojo
' Add some items
base.AddMenu(New MenuItem("Test 1"))
base.AddMenu(New MenuItem("Test 2"))
base.AddMenu(New MenuItem("Test 3"))

' Add a Separator
base.AddMenu(New MenuItem(MenuItem.TextSeparator))

' Add a sub menu
Var submenu As New MenuItem("SubMenu")
submenu.AddMenu(New MenuItem("SubMenu Test 1"))
submenu.AddMenu(New MenuItem("SubMenu Test 2"))
submenu.AddMenu(New MenuItem("SubMenu Test 3"))
base.AddMenu(submenu)

' Add a Separator
base.AddMenu(New MenuItem(MenuItem.TextSeparator))

Return True
```

<div id="segmentedbutton.contextualmenuaction">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.ContextualMenuAction

**ContextualMenuAction**(HitItem As `MenuItem</api/deprecated/menuitem>`) As `Boolean</api/data_types/boolean>`

Fires when a contextual menuitem *hitItem* was selected but the Action event and the MenuHandler for the menuitem did not handle the menu selection.

This event gives you a chance to handle the menu selection by inspecting the menuitem's Text or Tag properties to see which item was selected. Use this in conjunction with ConstructContextualMenu if you have not specified the Action event or the Menu Handler for the items on the contextual menu. See the example of a contextual menu in the examples for the **RectControl** class.

`Return</api/language/return>` `True</api/language/true>` if this event has handled the item the user chose from the contextual menu. Returning `False</api/language/false>` will cause the control's parent to execute its ContextualMenuAction event. This can be handy if you have the same contextual menu for several controls who share the same `Parent<rectcontrol.parent>` (several on the same window for example). By returning `False</api/language/false>` you can handle them all in a single event.

This simple event handler displays the value of the selected menu item.

``` xojo
If hitItem <> Nil Then MessageBox(hitItem.Value)
Return True
```

<div id="segmentedbutton.dragenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.DragEnter

**DragEnter**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` enters the RectControl.

Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.

The Action parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Value | Class Constant                                                     |
|-------|--------------------------------------------------------------------|
| 0     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault |
| 1     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy    |
| 2     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove    |
| 3     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink    |

To restrict file drops to just folders (and not files), you can put this code in the DragEnter event:

``` xojo
If Not obj.FolderItem.IsFolder Then Return True
```

<div id="segmentedbutton.dragexit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.DragExit

**DragExit**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`)

Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` exits the RectControl.

The *Obj* parameter is the item being dragged. The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Value | Constant                                                           |
|-------|--------------------------------------------------------------------|
| 0     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault |
| 1     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy    |
| 2     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove    |
| 3     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink    |

<div id="segmentedbutton.dragover">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.DragOver

**DragOver**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

Fires when the `DragItem</api/user_interface/desktop/dragitem>` is over the RectControl.

The *Obj* parameter is the object being dragged. The coordinates x and y are relative to the **RectControl**. Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` from this event to prevent the drop from occurring.

The *Action* parameter specifies the drag action, which is typically done by holding down a modifier key (Shift, Alt, Option, Command, etc.) while doing the drag. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

| Value | Constant                                                           |
|-------|--------------------------------------------------------------------|
| 0     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault |
| 1     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy    |
| 2     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove    |
| 3     | `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink    |

<div id="segmentedbutton.dropobject">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.DropObject

**DropObject**(Obj As `DragItem</api/user_interface/desktop/dragitem>` Action As `Integer</api/data_types/integer>`)

The item represented by *Obj* has been dropped on the control.

The *Obj* parameter is the object being dragged. The *Action* parameter specifies the drag action. It can take the following class constants of the `DragItem</api/user_interface/desktop/dragitem>` class:

{\| class="genericTable" ! width=10% Class Constant 0 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionDefault 1 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionCopy 2 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionMove 3 \| `DragItem</api/user_interface/desktop/dragitem>`.DragActionLink }

The following DropObject event handler can handle either a dropped picture or a dropped file. The type of file that it can handle needs to have been specified in a call to AcceptFileDrop prior to the drop, for example, in the opening event.

``` xojo
If Obj.PictureAvailable Then
  Me.Image = obj.Picture
ElseIf Obj.FolderItemAvailable Then
  Me.Image = Picture.Open(obj.FolderItem)
End If
```

<div id="segmentedbutton.keydown">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.KeyDown

**KeyDown**(Key As `String</api/data_types/string>`) As `Boolean</api/data_types/boolean>`

The user has pressed the *Key* passed while the `control</api/deprecated/rectcontrol>` has the focus.

How KeyDown works depends on the type of control.

**TextField and TextArea** Returning `True</api/language/true>` means the key is intercepted, preventing the key from actually reaching the control at all. This would be useful if you want to override the behavior of the tab key for example. Returning `False</api/language/false>` means the key reaches the control.

**All Other Controls** Returning `True</api/language/true>` prevents the KeyDown event on the parent control (usually the window) from executing. Returning `False</api/language/false>` results in the execution of the KeyDown event of the parent control.

<div id="segmentedbutton.keyup">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.KeyUp

**KeyUp**(Key As `String</api/data_types/string>`)

Fires when the passed *Key* is released in the RectControl that has the focus.

It is not guaranteed to be the same key that received the KeyDown event.

<div id="segmentedbutton.mouseenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseEnter

**MouseEnter**

The mouse has entered the area of the control.

<div id="segmentedbutton.mouseexit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseExit

**MouseExit**

The mouse has left the area of the control.

<div id="segmentedbutton.mousemove">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseMove

**MouseMove**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`)

The mouse has moved within the control to the coordinates passed. The coordinates are local to the control, not to the window.

<div id="segmentedbutton.mousewheel">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.MouseWheel

**MouseWheel**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`) As `Boolean</api/data_types/boolean>`

The mouse wheel has been moved.

The parameters *X* and *Y* are the mouse coordinates relative to the control that has received the event. The parameters *DeltaX* and *DeltaY* hold the number of scroll lines the wheel has been moved horizontally and vertically, as defined by the operating system. *DeltaX* is positive when the user scrolls right and negative when scrolling to the left. *DeltaY* is positive when the user scrolls down and negative when scrolling up.

Returns a `Boolean</api/data_types/boolean>`. Return `True</api/language/true>` to prevent the event from propagating further.

<div id="segmentedbutton.open">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Open

**Open**

The control is about to be displayed. Use this event to initialize a control.

The opening event is called after the Constructor.

Be warned that initializing control property values using the Constructor instead of the opening event may result in those property values being overwritten by what is set in the Inspector. For best results, use the opening event for control initialization rather than the control Constructor.

If the control is supposed to handle drag and drop, you need to tell it which type of item it needs to be able to handle. The following example informs the control that pictures and files can be dropped on it. The type of the file it needs to support is specified via the File Types Editor.

``` xojo
Sub Open()
  Me.AcceptPictureDrop
  Me.AcceptFileDrop("JPEG")
End Sub
```

<div id="segmentedbutton.pressed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

SegmentedButton.Pressed

**Pressed**(segmentIndex As Integer)

One of the segments was pressed or otherwise activated.

Check the `SelectedSegmentIndex<segmentedbutton.selectedsegmentindex>` to determine which segment was pressed.

## Notes

The easiest way to configure a <span class="title-ref">SegmentedButton</span> is to use the Segment Edit dialog in the IDE by clicking "Edit" in the Inspector. With it, you can create, delete, or reorder segments, label them, add an icon, and choose the selected segment or segments. (If the `SelectionStyle<segmentedbutton.selectionstyle>` is Multiple, you can have more than one selected segment.)

You set the behavior of the control with the `SelectionStyle<segmentedbutton.selectionstyle>` property. It enables you to choose whether the set of segments behaves as a group of radio buttons, a group of checkboxes, or a group of pushbutton. If it behaves like a group of checkboxes (Multiple), more than one can be selected at the same time. If it behaves like a pushbutton (None), then it is "selected" only while the mouse is held down.

If you want to do this work using code, you can address each segment with the `Segment</api/user_interface/desktop/segment>` class. You instantiate an instance of this class for the segment that you want to address.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Resizing a segmented button

The individual segments do not automatically resize when the width of the <span class="title-ref">SegmentedButton</span> changes. You'll need to individually change the widths of each segment to to fit the new width of the control. This code (in the Resized event handler of a Window) resizes the segments to fit the new width of the \`SegmentedButton\`:

``` xojo
SegmentedButton1.Width = Self.Width - SegmentedButton1.Left * 2

Const kPadding = 4
Var segWidth As Integer = (SegmentedButton1.Width / (SegmentedButton1.SegmentCount)) - kPadding
For i As Integer = 0 To SegmentedButton1.LastSegmentIndex
  SegmentedButton1.SegmentAt(i).Width = segWidth
Next

SegmentedButton1.ResizeSegmentsToFit()
```

## Sample code

If you have placed an instance on a window, called SegmentedButton1, you can set or get the properties of any one segment with code like the following

``` xojo
Var s As Segment
s = SegmentedButton1.SegmentAt(0) 
If s.Selected Then
  ' code
Else
  ' more code
End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

When a segment is selected the Pressed event runs and is passed the index of the segment that was pressed:

``` xojo
If segmentIndex = 0 Then
  ' code for when segment 0 is selected
Else
  ' code for when segment 1 is selected
End If
```

## Compatibility

All project types on all supported operating systems.

## See also

`RectControl</api/deprecated/rectcontrol>` parent class; `PushButton</api/deprecated/pushbutton>`, `Segment</api/user_interface/desktop/segment>` classes
