Class

# DesktopSegmentedButton

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

## 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<desktopsegmentedbutton.active>`                             | `Boolean</api/data_types/boolean>`                         | ✓         |        |
| `AllowAutoDeactivate<desktopsegmentedbutton.allowautodeactivate>`   | `Boolean</api/data_types/boolean>`                         |           |        |
| `AllowTabStop<desktopsegmentedbutton.allowtabstop>`                 | `Boolean</api/data_types/boolean>`                         |           |        |
| `Enabled<desktopsegmentedbutton.enabled>`                           | `Boolean</api/data_types/boolean>`                         |           |        |
| `Handle<desktopsegmentedbutton.handle>`                             | `Ptr</api/data_types/additional_types/ptr>`                | ✓         |        |
| `Height<desktopsegmentedbutton.height>`                             | `Integer</api/data_types/integer>`                         |           |        |
| `Index<desktopsegmentedbutton.index>`                               | `Integer</api/data_types/integer>`                         |           |        |
| `LastSegmentIndex<desktopsegmentedbutton.lastsegmentindex>`         | `Integer</api/data_types/integer>`                         | ✓         |        |
| `Left<desktopsegmentedbutton.left>`                                 | `Integer</api/data_types/integer>`                         |           |        |
| `LockBottom<desktopsegmentedbutton.lockbottom>`                     | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockLeft<desktopsegmentedbutton.lockleft>`                         | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockRight<desktopsegmentedbutton.lockright>`                       | `Boolean</api/data_types/boolean>`                         |           |        |
| `LockTop<desktopsegmentedbutton.locktop>`                           | `Boolean</api/data_types/boolean>`                         |           |        |
| `MacButtonStyle<desktopsegmentedbutton.macbuttonstyle>`             | `MacButtonStyles<desktopsegmentedbutton.macbuttonstyles>`  |           |        |
| `MouseCursor<desktopsegmentedbutton.mousecursor>`                   | `MouseCursor</api/user_interface/desktop/mousecursor>`     |           |        |
| `Name<desktopsegmentedbutton.name>`                                 | `String</api/data_types/string>`                           | ✓         |        |
| `PanelIndex<desktopsegmentedbutton.panelindex>`                     | `Integer</api/data_types/integer>`                         |           |        |
| `Parent<desktopsegmentedbutton.parent>`                             | `Object</api/data_types/additional_types/object>`          |           |        |
| `Scope<desktopsegmentedbutton.scope>`                               | `Integer</api/data_types/integer>`                         | ✓         |        |
| `SegmentCount<desktopsegmentedbutton.segmentcount>`                 | `Integer</api/data_types/integer>`                         | ✓         |        |
| `SelectedSegment<desktopsegmentedbutton.selectedsegment>`           | `Segment</api/user_interface/desktop/segment>`             | ✓         |        |
| `SelectedSegmentIndex<desktopsegmentedbutton.selectedsegmentindex>` | `Integer</api/data_types/integer>`                         |           |        |
| `SelectionStyle<desktopsegmentedbutton.selectionstyle>`             | `SelectionStyles<desktopsegmentedbutton.selectionstyles>`  |           |        |
| `TabIndex<desktopsegmentedbutton.tabindex>`                         | `Integer</api/data_types/integer>`                         |           |        |
| `Tooltip<desktopsegmentedbutton.tooltip>`                           | `String</api/data_types/string>`                           |           |        |
| `Top<desktopsegmentedbutton.top>`                                   | `Integer</api/data_types/integer>`                         |           |        |
| `Transparent<desktopsegmentedbutton.transparent>`                   | `Boolean</api/data_types/boolean>`                         |           |        |
| `Visible<desktopsegmentedbutton.visible>`                           | `Boolean</api/data_types/boolean>`                         |           |        |
| `Width<desktopsegmentedbutton.width>`                               | `Integer</api/data_types/integer>`                         |           |        |
| `Window<desktopsegmentedbutton.window>`                             | `DesktopWindow</api/user_interface/desktop/desktopwindow>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                              | Parameters                                                                                                                                                                                                                                                    | Returns                                        | Shared |
|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|--------|
| `AcceptFileDrop<desktopsegmentedbutton.acceptfiledrop>`           | FileType As `String</api/data_types/string>`                                                                                                                                                                                                                  |                                                |        |
| `AcceptPictureDrop<desktopsegmentedbutton.acceptpicturedrop>`     |                                                                                                                                                                                                                                                               |                                                |        |
| `AcceptRawDataDrop<desktopsegmentedbutton.acceptrawdatadrop>`     | Type As `String</api/data_types/string>`                                                                                                                                                                                                                      |                                                |        |
| `AcceptTextDrop<desktopsegmentedbutton.accepttextdrop>`           |                                                                                                                                                                                                                                                               |                                                |        |
| `AddSegment<desktopsegmentedbutton.addsegment>`                   | segment As `Segment</api/user_interface/desktop/segment>`                                                                                                                                                                                                     |                                                |        |
| `AddSegmentAt<desktopsegmentedbutton.addsegmentat>`               | index As `Integer</api/data_types/integer>`, segment As `Segment</api/user_interface/desktop/segment>`                                                                                                                                                        |                                                |        |
| `Close<desktopsegmentedbutton.close>`                             |                                                                                                                                                                                                                                                               |                                                |        |
| `DrawInto<desktopsegmentedbutton.drawinto>`                       | g As `Graphics</api/graphics/graphics>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                                                                                                                                     |                                                |        |
| `Refresh<desktopsegmentedbutton.refresh>`                         | immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`                                                                                                                                                                              |                                                |        |
|                                                                   | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>` |                                                |        |
| `RemoveAllSegments<desktopsegmentedbutton.removeallsegments>`     |                                                                                                                                                                                                                                                               |                                                |        |
| `RemoveSegmentAt<desktopsegmentedbutton.removesegmentat>`         | index As `Integer</api/data_types/integer>`                                                                                                                                                                                                                   |                                                |        |
| `ResizeSegmentsToFit<desktopsegmentedbutton.resizesegmentstofit>` |                                                                                                                                                                                                                                                               |                                                |        |
| `SegmentAt<desktopsegmentedbutton.segmentat>`                     | index As `Integer</api/data_types/integer>`                                                                                                                                                                                                                   | `Segment</api/user_interface/desktop/segment>` |        |
| `SetFocus<desktopsegmentedbutton.setfocus>`                       |                                                                                                                                                                                                                                                               |                                                |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                                            | Parameters                                                                                                                                                                            | Returns                            |
|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `Closing<desktopsegmentedbutton.closing>`                                       |                                                                                                                                                                                       |                                    |
| `ConstructContextualMenu<desktopsegmentedbutton.constructcontextualmenu>`       | Base As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`, x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`                              | `Boolean</api/data_types/boolean>` |
| `ContextualMenuItemSelected<desktopsegmentedbutton.contextualmenuitemselected>` | HitItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`                                                                                                             | `Boolean</api/data_types/boolean>` |
| `DragEnter<desktopsegmentedbutton.dragenter>`                                   | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   | `Boolean</api/data_types/boolean>` |
| `DragExit<desktopsegmentedbutton.dragexit>`                                     | obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `DragOver<desktopsegmentedbutton.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 `DragItem.Types<dragitem.types>` | `Boolean</api/data_types/boolean>` |
| `DropObject<desktopsegmentedbutton.dropobject>`                                 | obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `DragItem.Types<dragitem.types>`                                                                                   |                                    |
| `FocusLost<desktopsegmentedbutton.focuslost>`                                   |                                                                                                                                                                                       |                                    |
| `FocusReceived<desktopsegmentedbutton.focusreceived>`                           |                                                                                                                                                                                       |                                    |
| `KeyDown<desktopsegmentedbutton.keydown>`                                       | Key As `String</api/data_types/string>`                                                                                                                                               | `Boolean</api/data_types/boolean>` |
| `KeyUp<desktopsegmentedbutton.keyup>`                                           | Key As `String</api/data_types/string>`                                                                                                                                               |                                    |
| `MouseDown<desktopsegmentedbutton.mousedown>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      | `Boolean</api/data_types/boolean>` |
| `MouseDrag<desktopsegmentedbutton.mousedrag>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseEnter<desktopsegmentedbutton.mouseenter>`                                 |                                                                                                                                                                                       |                                    |
| `MouseExit<desktopsegmentedbutton.mouseexit>`                                   |                                                                                                                                                                                       |                                    |
| `MouseMove<desktopsegmentedbutton.mousemove>`                                   | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseUp<desktopsegmentedbutton.mouseup>`                                       | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`                                                                                                      |                                    |
| `MouseWheel<desktopsegmentedbutton.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>` |
| `Opening<desktopsegmentedbutton.opening>`                                       |                                                                                                                                                                                       |                                    |
| `Pressed<desktopsegmentedbutton.pressed>`                                       | segmentIndex As `Integer</api/data_types/integer>`                                                                                                                                    |                                    |

## Enumerations

<div id="desktopsegmentedbutton.macbuttonstyles">

<div class="rst-class">

forsearch

</div>

</div>

DesktopSegmentedButton.MacButtonStyles

### MacButtonStyles

> Specifies the various segmented button styles when the control is displayed on macOS.
>
> | Style           |
> |-----------------|
> | Automatic       |
> | Capsule         |
> | RoundRectangle  |
> | Rounded         |
> | TexturedRounded |
> | TexturedSquare  |
> | SmallSquare     |
> | Separated       |

<div id="desktopsegmentedbutton.selectionstyles">

<div class="rst-class">

forsearch

</div>

</div>

DesktopSegmentedButton.SelectionStyles

### SelectionStyles

Specifies the different styles of selection available.

> | 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 buttons, no segment can remained selected once pressed.      |

## Property descriptions

<div id="desktopsegmentedbutton.active">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Active

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

> Indicates whether the `control</api/user_interface/desktop/desktopuicontrol>` is active.
>
> Active is `False</api/language/false>` when the control's window is not in the foreground. When a `DesktopWindow</api/user_interface/desktop/desktopwindow>` is deactivated, its controls are automatically deactivated unless `AllowAutoDeactivate<desktopuicontrol.allowautodeactivate>` is set to `False</api/language/false>`.
>
> This property is read-only.

<div id="desktopsegmentedbutton.allowautodeactivate">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.allowtabstop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.AllowTabStop

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

> If `True</api/language/true>`, the control 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 control 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="desktopsegmentedbutton.enabled">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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.
>
> ``` xojo
> Me.Enabled = False
> ```

<div id="desktopsegmentedbutton.handle">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> Returns a handle to the control.
>
> This property is read-only.
>
> For interfacing with Mac APIs using `Declares</api/language/declare>`, **DesktopControl.Handle** returns NSViews (except for `DesktopToolbar</api/user_interface/desktop/desktoptoolbar>`).
>
> On Windows returns the HWND of the control.
>
> On Linux it returns a GtkWidget.
>
> The following gets a handle to the control.
>
> ``` xojo
> Var p As Ptr = Me.Handle
> ```

<div id="desktopsegmentedbutton.height">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.index">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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.

<div id="desktopsegmentedbutton.lastsegmentindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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">DesktopSegmentedButton</span>.
>
> This property is read-only.

<div id="desktopsegmentedbutton.left">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Left

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

> The distance from the left side of the control to the left side of its containing window or container.
>
> The following example moves the control 100 points from the left side of the window:
>
> ``` xojo
> Me.Left = 150
> ```

<div id="desktopsegmentedbutton.lockbottom">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.lockleft">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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.
>
> 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="desktopsegmentedbutton.lockright">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.locktop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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.
>
> 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="desktopsegmentedbutton.macbuttonstyle">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.MacButtonStyle

**MacButtonStyle** As `MacButtonStyles<desktopsegmentedbutton.macbuttonstyles>`

> Controls the appearance of the <span class="title-ref">DesktopSegmentedButton</span> on macOS.
>
> Use `MacButtonStyles<desktopsegmentedbutton.macbuttonstyles>` to set/get this property.
>
> Not all button styles are available on all versions of macOS.
>
> ![image](images/desktopsegmentedbutton.png)
>
> This code is in the Opening event of the control but will only take effect when building for macOS. It sets the style to Rounded.
>
> ``` xojo
> Me.MacButtonStyle = DesktopSegmentedButton.MacButtonStyles.Rounded
> ```

<div id="desktopsegmentedbutton.mousecursor">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 `DesktopWindow</api/user_interface/desktop/desktopwindow>` 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 `DesktopWindow</api/user_interface/desktop/desktopwindow>`'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="desktopsegmentedbutton.name">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.panelindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.PanelIndex

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

> If the control has been placed on a `DesktopTabPanel</api/user_interface/desktop/desktoptabpanel>` or `DesktopPagePanel</api/user_interface/desktop/desktoppagepanel>` 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 `DesktopTabPanel</api/user_interface/desktop/desktoptabpanel>` or `DesktopPagePanel</api/user_interface/desktop/desktoppagepanel>` control, it returns the panel number. If the control is not on a `DesktopPagePanel</api/user_interface/desktop/desktoppagepanel>` or `DesktopTabPanel</api/user_interface/desktop/desktoptabpanel>`, 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 `DesktopPagePanel<desktoppagepanel.selectedpanelindex>`.
>
> This code displays the panel index of the control that is on the page.
>
> ``` xojo
> MessageBox(Me.SelectedPanelIndex.ToString)
> ```

<div id="desktopsegmentedbutton.parent">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Parent

**Parent** As `Object</api/data_types/additional_types/object>`

> Used to get and set the control's parent control or window.
>
> If the control is on the window, the Parent will be the `Window</api/user_interface/desktop/desktopwindow>`. If the control is on the container, the Parent will be the `container</api/user_interface/desktop/desktopcontainer>`. If the control is completed enclosed by another control, the Parent will be that `control</api/user_interface/desktop/desktopuicontrol>`.
>
> If you do not want the enclosing control to be the parent, set the Parent property of that control to `Nil</api/language/nil>` to make it the `Window</api/user_interface/desktop/desktopwindow>`.
>
> 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="desktopsegmentedbutton.scope">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This is a designtime-only property and thus can only be set in the Inspector and is not accessible via code.
>
> </div>
>
> If the Scope of a control is set to Private, it cannot be accessed from outside its parent window.

<div id="desktopsegmentedbutton.segmentcount">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.SegmentCount

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

> The number of `Segments</api/user_interface/desktop/segment>` in the <span class="title-ref">DesktopSegmentedButton</span>.
>
> This property is read-only.
>
> This example displays the number of segments in the <span class="title-ref">DesktopSegmentedButton</span>.
>
> ``` xojo
> MessageBox(SegmentedButton1.SegmentCount.ToString)
> ```

<div id="desktopsegmentedbutton.selectedsegment">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.selectedsegmentindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 SegmentedButton control. SelectedSegmentIndex is only useful when `SelectionStyle<desktopsegmentedbutton.selectionstyle>` is set to Single. `SelectedSegment<desktopsegmentedbutton.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<desktopsegmentedbutton.selectionstyle>` is set to Multiple, you must use `SegmentAt<desktopsegmentedbutton.segmentat>` to check each segment's `Selected<segment.selected>` property to see if it's `True</api/language/true>` or not.
>
> The following example changes the selected segment to the third segment:
>
> ``` xojo
> SegmentedButton1.SelectedSegmentIndex = 2
> ```

<div id="desktopsegmentedbutton.selectionstyle">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.SelectionStyle

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

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

<div id="desktopsegmentedbutton.tabindex">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.TabIndex

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

> The control's position in the Tab Order. The control with whose TabIndex is 0 will get the focus first.
>
> On macOS, only controls where you enter data from the keyboard typically get the focus. In order to manually set focus to controls that don't allow keyboard entry, go to System Preferences, click on the Keyboard icon then on the Shortcuts tab and then check the *Use keyboard navigation to move focus between controls* checkbox.
>
> This example sets the control's TabIndex.
>
> ``` xojo
> Me.TabIndex = 2
> ```

<div id="desktopsegmentedbutton.tooltip">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 control:
>
> ``` xojo
> Me.Tooltip = "Click to bark."
> ```

<div id="desktopsegmentedbutton.top">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Top

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

> The distance from the top of the control to the top of its containing window or container.
>
> This example sets the top of the control to 140 points from the top of the window:
>
> ``` xojo
> Me.Top = 140
> ```

<div id="desktopsegmentedbutton.transparent">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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</api/language/false>`.
>
> For projects that were created prior to 2018r1, this property defaults to `True</api/language/true>` to emulate previous behavior. Consider changing it to `False</api/language/false>` to improve performance if you do not require transparency.

<div id="desktopsegmentedbutton.visible">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 makes the control invisible:
>
> ``` xojo
> Me.Visible = False
> ```

<div id="desktopsegmentedbutton.width">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.window">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Window

**Window** As `DesktopWindow</api/user_interface/desktop/desktopwindow>`

> The control's parent window.
>
> This property is read-only.
>
> This code gets the parent window's Title property.
>
> ``` xojo
> MessageBox(Me.Window.Title)
> ```

## Method descriptions

<div id="desktopsegmentedbutton.acceptfiledrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 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 specific file types on macOS, in addition to creating a File Type (as a `project item</getting_started/using_the_ide/file_type_group_editor>` or `via code</api/files/filetype>`) to define the file extension, you must also use the `DragEnter<desktopuicontrol.dragenter>` event:
>
> For example, to restrict drops to folders only:
>
> ``` xojo
> If Not obj.FolderItem.IsFolder Then Return True
> ```
>
> To restrict drops to a files with a specific extension:
>
> ``` xojo
> If Not obj.FolderItem.Extension <> ".my_extension" Then Return True
> ```

<div id="desktopsegmentedbutton.acceptpicturedrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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<desktopuicontrol.dropobject>` event is called and this is where you will put your code to handle the drop.
>
> Opening Event:
>
> ``` xojo
> Me.AcceptPictureDrop
> ```
>
> DropObject Event:
>
> ``` xojo
> If obj.PictureAvailable Then
>   Me.Backdrop = obj.Picture
> End If
> ```

<div id="desktopsegmentedbutton.acceptrawdatadrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.accepttextdrop">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.addsegment">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 `Opening<desktopcontrol.opening>` event of the control adds a segment to it:
>
> ``` xojo
> Var seg As New Segment
> seg.Title = "Banana"
> Me.AddSegment(seg)
> ```

<div id="desktopsegmentedbutton.addsegmentat">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.close">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.drawinto">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 control into the specified `Graphics</api/graphics/graphics>` context. The parameters *x* and *y* are the coordinates of the top, left corner.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> DrawInto will only work if the control is on a window or container.
>
> </div>
>
> 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="desktopsegmentedbutton.refresh">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Refresh

**Refresh**(immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Redraws the portion specified of the contents of the control the next time the OS redraws the control or immediately if `True</api/language/true>` is passed.
>
> If you are calling this so frequently that you experience a slowdown in your code, pass `True</api/language/true>` for the immediately parameter.
>
> Calling this method causes the Render event to fire.
>
> Refresh the entire area immediately:
>
> ``` xojo
> Me.Refresh(True)
> ```

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

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Refresh

**Refresh**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, width As `Integer</api/data_types/integer>`, height As `Integer</api/data_types/integer>`, immediately As `Boolean</api/data_types/boolean>` = `False</api/language/false>`)

> Redraws the portion specified of the contents of the control the next time the OS redraws the control or immediately if `True</api/language/true>` is passed.
>
> Refresh a portion of the area the next time the OS redraws the control:
>
> ``` xojo
> Me.Refresh(100, 150, 200, 300)
> ```

<div id="desktopsegmentedbutton.removeallsegments">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.RemoveAllSegments

**RemoveAllSegments**

> Removes all segments in the control.
>
> The following example (in any event of a <span class="title-ref">DesktopSegmentedButton</span> removes all the existing segments:
>
> ``` xojo
> Me.RemoveAllSegments
> ```

<div id="desktopsegmentedbutton.removesegmentat">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.resizesegmentstofit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 a `Segment</api/user_interface/desktop/segment>`'s `Width<segment.width>` is set to 0, <span class="title-ref">ResizeSegmentsToFit</span> calculates the minimum width needed to contain that segment's caption and icon and uses that width when sizing the control. The `Width<segment.width>` property of the segment remains 0 after the call.
>
> If you add a new segment, the SegmentedButton 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 SegmentedButton width the same then you will want to resize the individual segments to fit within the SegmentedButton 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">DesktopSegmentedButton</span>'s properties on the fly. For example, this code on a `DesktopButton</api/user_interface/desktop/desktopbutton>` 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="desktopsegmentedbutton.segmentat">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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">DesktopSegmentedButton</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 " + SegmentedButton1.SegmentCount.ToString
>
> 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="desktopsegmentedbutton.setfocus">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.SetFocus

**SetFocus**

> If applicable, sets the focus to the DesktopUIControl. 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 `DesktopWindow</api/user_interface/desktop/desktopwindow>` 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.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On macOS, you need Full Keyboard Access turned on in System Preferences (Keyboard-\>Shortcuts) in order to manually set focus to non-text controls.
>
> </div>
>
> The following example in the Opening event sets the focus to the that control. If another control has the focus when this line is executed, then the user sees this control gets the focus.
>
> ``` xojo
> Me.SetFocus
> ```

## Event descriptions

<div id="desktopsegmentedbutton.closing">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Closing

**Closing**

> The control is closing.

<div id="desktopsegmentedbutton.constructcontextualmenu">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.ConstructContextualMenu

**ConstructContextualMenu**(Base As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`, 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<desktopuicontrol.mouseup>` or `MouseDown<desktopuicontrol.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 DesktopMenuItem("Test 1"))
> base.AddMenu(New DesktopMenuItem("Test 2"))
> base.AddMenu(New DesktopMenuItem("Test 3"))
>
> ' Add a Separator
> base.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
>
> ' Add a sub menu
> Var submenu As New DesktopMenuItem("SubMenu")
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 1"))
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 2"))
> submenu.AddMenu(New DesktopMenuItem("SubMenu Test 3"))
> base.AddMenu(submenu)
>
> ' Add a Separator
> base.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
>
> Return True
> ```

<div id="desktopsegmentedbutton.contextualmenuitemselected">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.ContextualMenuItemSelected

**ContextualMenuItemSelected**(HitItem As `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>`) As `Boolean</api/data_types/boolean>`

> Fires when a contextual menuitem *selectedItem* was selected but the `MenuItemSelected<desktopmenuitem.menuitemselected>` event and the MenuHandler for the `DesktopMenuItem</api/user_interface/desktop/desktopmenuitem>` 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 `MenuItemSelected<desktopmenuitem.menuitemselected>` event or the Menu Handler for the items on the contextual menu. See the example of a contextual menu in the examples for the **DesktopUIControl** 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 ContextualMenuItemSelected event. This can be handy if you have the same contextual menu for several controls who share the same `Parent<desktopuicontrol.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 selectedItem <> Nil Then MessageBox(selectedItem.Text)
> Return True
> ```

<div id="desktopsegmentedbutton.dragenter">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.DragEnter

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

> Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` enters the DesktopUIControl.
>
> 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 type of drag action.
>
> 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="desktopsegmentedbutton.dragexit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.DragExit

**DragExit**(obj As `DragItem</api/user_interface/desktop/dragitem>`, Action As `DragItem.Types<dragitem.types>`)

> Fires when the passed `DragItem</api/user_interface/desktop/dragitem>` exits the DesktopUIControl.
>
> The *Obj* parameter is the item being dragged. The *Action* parameter specifies the type of drag action.

<div id="desktopsegmentedbutton.dragover">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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 `DragItem.Types<dragitem.types>`) As `Boolean</api/data_types/boolean>`

> Fires when the `DragItem</api/user_interface/desktop/dragitem>` is over the DesktopUIControl.
>
> The *Obj* parameter is the object being dragged. The coordinates x and y are relative to the **DesktopUIControl**. 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 type of drag action, which is typically done by holding down a modifier key (Shift, Alt, Option, Command, etc.) while doing the drag.

<div id="desktopsegmentedbutton.dropobject">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.DropObject

**DropObject**(obj As `DragItem</api/user_interface/desktop/dragitem>`, action As `DragItem.Types<dragitem.types>`)

> The item represented by *obj* has been dropped on the control.
>
> The *obj* parameter is the object being dragged. The *action* parameter specifies the type of drag action.
>
> 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="desktopsegmentedbutton.focuslost">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.FocusLost

**FocusLost**

> The `control</api/user_interface/desktop/desktopuicontrol>` has lost the focus.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On macOS, controls other than text fields and lists will accept and lose focus only if the full keyboard access option is enabled in System Preferences/Keyboard.
>
> </div>

<div id="desktopsegmentedbutton.focusreceived">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.FocusReceived

**FocusReceived**

> The `control</api/user_interface/desktop/desktopuicontrol>` has received the focus and has a selection rectangle around it.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> On macOS, controls other than text fields and lists will accept focus only if the full keyboard access option is enabled in System Preferences/Keyboard.
>
> </div>

<div id="desktopsegmentedbutton.keydown">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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/user_interface/desktop/desktopuicontrol>` has the focus.
>
> 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="desktopsegmentedbutton.keyup">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.KeyUp

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

> Fires when the passed *Key* is released in the control that has the focus.
>
> It is not guaranteed to be the same key that received the KeyDown event.

<div id="desktopsegmentedbutton.mousedown">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.MouseDown

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

> The mouse button was pressed inside the control's region at the location passed in to *x*, *y*.
>
> This event fires repeatedly while the mouse button is being held down.
>
> The coordinates *x* and *y* are local to the control, i.e. they represent the position of the mouse click relative to the upper-left corner of the `control</api/user_interface/desktop/desktopuicontrol>`.
>
> `Return</api/language/return>` `True</api/language/true>` if you are going to handle the MouseDown. In such a case:
>
> - The Pressed event, if any, will not execute and the state of the object will not change.
> - You will receive the `MouseUp<desktopuicontrol.mouseup>` event.
>
> If you return `False</api/language/false>`, the system handles the MouseDown so the `MouseUp<desktopuicontrol.mouseup>` event handler does not get called.
>
> The MouseDown event uses the `DragItem</api/user_interface/desktop/dragitem>` constructor when the user drags the contents of the control. It is:
>
> ``` xojo
> Var d As DragItem
> d = New DragItem(Self, Me.Left, Me.Top, Me.Width, Me.Height)
> d.Picture = Me.Image
> d.Drag ' Allow the drag
> ```

<div id="desktopsegmentedbutton.mousedrag">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.MouseDrag

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

> The mouse button was pressed inside the control and moved (dragged) at the location local to the control passed in to *x*, *y*.
>
> This event fires repeatedly while the mouse button is down regardless of whether or not the mouse coordinates are changing.
>
> This event will not occur unless you return `True</api/language/true>` in the MouseDown event.

<div id="desktopsegmentedbutton.mouseenter">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.MouseEnter

**MouseEnter**

> The mouse has entered the area of the control.

<div id="desktopsegmentedbutton.mouseexit">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.MouseExit

**MouseExit**

> The mouse has left the area of the control.

<div id="desktopsegmentedbutton.mousemove">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.mouseup">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.MouseUp

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

> The mouse button was released. Use the *x* and *y* parameters to determine if the mouse button was released within the control's boundaries.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> This event will not occur unless you return `True</api/language/true>` in the MouseDown event. The return value is ignored.
>
> </div>
>
> The parameters *x* and *y* are local coordinates, i.e. they represent the position of the mouse click relative to the upper-left corner of the `control</api/user_interface/desktop/desktopuicontrol>`. Mouse clicks that are released to the left or above a control are negative.

<div id="desktopsegmentedbutton.mousewheel">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.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="desktopsegmentedbutton.opening">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Opening

**Opening**

> 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 Opening()
>   Me.AcceptPictureDrop
>   Me.AcceptFileDrop("JPEG")
> End Sub
> ```

<div id="desktopsegmentedbutton.pressed">

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

</div>

<div class="rst-class">

forsearch

</div>

DesktopSegmentedButton.Pressed

**Pressed**(segmentIndex As `Integer</api/data_types/integer>`)

> One of the segments was pressed or otherwise activated.
>
> Check the `SelectedSegmentIndex<desktopsegmentedbutton.selectedsegmentindex>` to determine which segment was pressed.

## Notes

The easiest way to configure a SegmentedButton 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<desktopsegmentedbutton.selectionstyle>` is Multiple, you can have more than one selected segment.)

You set the behavior of the control with the `SelectionStyle<desktopsegmentedbutton.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 button. If it behaves like a group of checkboxes (Multiple), more than one can be selected at the same time. If it behaves like a button (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 SegmentedButton 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

|                       |         |
|-----------------------|---------|
| **Project Types**     | Desktop |
| **Operating Systems** | All     |

<div class="seealso">

`DesktopUIControl</api/user_interface/desktop/desktopuicontrol>` parent class; `DesktopButton</api/user_interface/desktop/desktopbutton>`, `Segment</api/user_interface/desktop/segment>` classes

</div>
