---
title: "DragSource (Generic)"
canonical: "https://docs.cuesystem.com/space/CVCGC/419987464/DragSource%20(Generic)"
format: markdown
---
> Macro (toc)

---

# Description

The DragSource and DropDestination are two objects designed for matrix based combination settings. Any DragSource can be dragged and dropped to DropDestination in the same Join group. The event is generated when object DragSource is dropped over the object DropDestination and this is a moment when real device is switched (for example AV matrix switcher, audio processor, etc...). ObjectID of the DragSource is delivered in the parameter of event.

DragSource contains text (typically source name) and picture. Both of them are delivered to DropDestination object when drop is done and can be displayed. This ensures possibility to display source selected for specific destination. In addition DragDestination object offers function SetSource which allows to set source from program. Typically it can be used in presets like “set the same source to all destinations”. Unlimited number of sources represented by DragSource objects and unlimited number of destinations represented by DropSource objects can be combined.

See following figure and example for better understanding.

![image](media://6a12b8ff-e29d-4b54-9fdf-b2f6a7ed2fa7)

## Example

Following figure describes how to use DragSource and DropDestination in practice. There are four sources connected to matrix switcher inputs and two display devices connected to matrix switcher outputs. By drag and drop you control matrix switcher and any combination of sources and destinations can be set.

![image](media://acf3a2d6-aca5-4062-929e-5d3d59a90ca6)

# Properties

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| Property Name | Data Type | Allowed Values | Default Value | Description |
| Behavior |
| Join |  | Joins created for DragSource and DropDestination objects joining. | Nothing | It is used for joining DragSource and DropDestination objects. It must be used for proper functionality. |
| ObjectID | Long | > 0 | 0 | It identifies source and this number is sent to DropDestination object when source is dropped. Set number > 0 |
| Disable mode | Long | 0 = None  
1 = Drag  
2 = DragAndTouch | 0 | DISABLE_MODE_NONE: enable drag and touch<br>DISABLE_MODE_DRAG: disable drag, enable touch<br>DISABLE_MODE_DRAG_AND_TOUCH: disable drag and touch |
| Appearance |
| BackgroundColor | Long |  | 0 (transparent) | Color of background |
| Picture |
| Fitting | Long | 0 = None  
1 = Fit Object to Content   
2 = Fit Content to Object   
3 = Center Content  
4 = Fit Content Proportionally  
5 = Fill Object Proportionally | 0 | Method of picture fitting.<br>For more details about fitting methods please see object PictureBox. |
| OffsetX | Long | Any | 0 | Horizontal offset of picture in pixels. |
| OffsetY | Long | Any | 0 | Vertical offset of picture in pixels. |
| Picture | AddressOf _Picture |  | Nothing | Picture placed to the object. |
| Text |
| Align | Long | Left-Top   
Left-Middle   
Left-Bottom Center-Top  
Center-Middle Center-Bottom Right-Top   
Right-Middle  
Right-Bottom | Center-Middle | Horizontal and vertical align of Text. |
| Color | Long | Any | _COLOR_BLACK | Color of Text |
| Font | AddressOf _Font | Any | fntDefault16 | Text font. fntDefault16 is Verdana 16 pixels high. |
| LineSpacing | Double | Any non-negative | 1.2 | Vertical distance between two lines of multiline content Text. The value is multiple of the font height. |
| Text | AddressOf Text | Any | Caption | Text shown as caption. |
| TextOffsetX | Long | Any | 0 | Horizontal offset of Text in pixels. |
| TextOffsetY | Long | Any | 0 | Vertical offset of Text in pixels. |

# Functions

## SetAlign

This function sets align of text. You can use meaningful BitOr combinations of the following constants as parameters

- _TEXT_ALIGNLEFT, _TEXT_ALIGNHCENTER, _TEXT_ALIGNRIGHT
- _TEXT_ALIGNTOP, _TEXT_ALIGNVCENTER, _TEXT_ALIGNBOTTOM

The function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function SetAlign(newalign As Long) As Boolean
```

## GetAlign

This function returns the current align of text.

#### Syntax

```visualbasic
Function GetAlign() As Long
```

## SetBackgroundColor

This function sets BackgroundColor to newbackgroundcolor. Function returns True.

#### Syntax

```visualbasic
Function SetBackgroundColor(newbackgroundcolor As Long) As Boolean
```

## GetBackgroundColor

This function returns current BackgroundColor.

#### Syntax

```visualbasic
Function GetBackgroundColor() As Long
```

## SetColor

This function sets text Color to newcolor. Function returns True.

#### Syntax

```visualbasic
Function SetColor(newcolor As Long) As Boolean
```

## GetColor

This function returns current text Color.

#### Syntax

```visualbasic
Function GetColor() As Long
```

## SetFitting

This function sets Fitting of Picture to newfitting. Possible parameters are

- 0 = None
- 1 = Fit Object to Content
- 2 = Fit Content to Object
- 3 = Center Content
- 4 = Fit Content Proportionally
- 5 = Fill Object Proportionally

Function returns True if parameter is 0 to 5, otherwise it returns False.

#### Syntax

```visualbasic
Function SetFitting(newfitting As Long) As Boolean
```

## GetFitting

This function returns current Fitting method.

#### Syntax

```visualbasic
Function GetFitting() As Long
```

## SetFont

This function sets the font of text. Function returns True.

#### Syntax

```visualbasic
Function SetFont(newfont As AddressOf _Font) As Boolean
```

## GetFont

This function returns address of text font.

#### Syntax

```visualbasic
Function GetFont() As AddressOf _Font
```

## SetLineSpacing

This function sets LineSpacing to newlinespacing. Function returns True if newlinespacing >= 0, otherwise it returns False.

#### Syntax

```visualbasic
Function SetLineSpacing(newlinespacing As Double) As Boolean
```

## GetLineSpacing

This function returns current LineSpacing.

#### Syntax

```visualbasic
Function GetLineSpacing() As Double
```

## SetPicture

This function sets Picture to newpicture. Function returns True.

#### Syntax

```visualbasic
Function SetPicture(newpicture As AddressOf _Picture) As Boolean
```

## GetPicture

This function returns address of current Picture.

#### Syntax

```visualbasic
Function GetPicture() As AddressOf _Picture
```

## SetPictureOffsetX

This function sets PictureOffsetX to newpictureoffsetx. Function returns True.

#### Syntax

```visualbasic
Function SetPictureOffsetX(newpictureoffsetx As Long) As Boolean
```

## GetPictureOffsetX

This function returns current PictureOffsetX.

#### Syntax

```visualbasic
Function GetPictureOffsetX() As Long
```

## SetPictureOffsetY

This function sets PictureOffsetY to newpictureoffsety. Function returns True.

#### Syntax

```visualbasic
Function SetPictureOffsetY(newpictureoffsety As Long) As Boolean
```

## GetPictureOffsetY

This function returns current PictureOffsetY.

#### Syntax

```visualbasic
Function GetPictureOffsetY() As Long
```

## SetText

This function sets Text to newtext. Function returns True.

#### Syntax

```visualbasic
Function SetText(newtext As Text) As Boolean
```

## GetText

This function returns address of current Text.

#### Syntax

```visualbasic
Function GetText() As AddressOf Text
```

## SetTextOffsetX

This function sets TextOffsetX to newtextoffsetx. Function returns True.

#### Syntax

```visualbasic
Function SetTextOffsetX(newtextoffsetx As Long) As Boolean
```

## GetTextOffsetX

This function returns current TextOffsetX.

#### Syntax

```visualbasic
Function GetTextOffsetX() As Long
```

## SetTextOffsetY

This function sets TextOffsetY to newtextoffsety. Function returns True.

#### Syntax

```visualbasic
Function SetTextOffsetY(newtextoffsety As Long) As Boolean
```

## GetTextOffsetY

This function returns current TextOffsetY.

#### Syntax

```visualbasic
Function GetTextOffsetY() As Long
```

## BringToFrontZOrder

This function temporarily brings the object to the very top position.

#### Syntax

```visualbasic
Function BringToFrontZOrder()
```

## RestoreZOrder

This function restores object’s z-order to value defined in design mode.

#### Syntax

```visualbasic
Function RestoreZOrder()
```

## SetDisableMode

This function sets DisableMode to disablemode. Possible parameters are

- 0 = DISABLE_MODE_NONE
- 1 = DISABLE_MODE_DRAG
- 2 = DISABLE_MODE_DRAG_AND_TOUCH

Function returns True if parameter is 0 to 2, otherwise it returns False.

#### Syntax

```visualbasic
Function SetDisableMode(disablemode As Long) As Boolean
```

## GetDisableMode

This function returns current DisableMode.

#### Syntax

```visualbasic
Function GetDisableMode() As Long
```

## WaitWhilePressed

This function waits for the end of object push. If optional timeout parameter is used, the maximum waiting time is limited by timeout value. In case of timeout excess, function returns False, otherwise it returns True.

#### Syntax

```visualbasic
Function WaitWhilePressed(Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## IsDragPressed

By this function you can test whether a button is pushed (function returns True) or not (return value is False). If DisabeMode is set to DISABLE_MODE_DRAG_AND_TOUCH, then the function returns false.

#### Syntax

```visualbasic
Function IsDragPressed() As Boolean
```

## SetObjectID

This function sets the ObjectID value. It should not be called at any time during runtime. The ObjectID is used at all times and identifies the source. This number is sent to DropDestination object when source is dropped. Set number > 0. The function returns true if the value is greater than 0.

#### Syntax

```
Function SetObjectID(newobjectid as long) As Boolean
```

## GetObjectID

This function returns ObjectID.

#### Syntax

```visualbasic
Function GetObjectID() As Long
```

# Events

## OnTouch

This event is generated when the object is touched and property Events is set to True.

#### Syntax

```visualbasic
Event OnTouch As Process()
```

## OnRelease

This event is generated when the object is released.

#### Syntax

```visualbasic
Event OnRelease As Process()
```