DgsSendDragNDropData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 43: Line 43:


addEventHandler("onDgsDrop",btn3,function(data)
addEventHandler("onDgsDrop",btn3,function(data)
iprint("Receive Data:",data)
outputChatBox("Receive Data: "..inspect(data))
end,false)
end,false)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 17:18, 23 March 2022

This function makes the possibility of transfering dynamic data between dgs elements by Drag&Drop, which is useful for inventory system.

Syntax

bool dgsSendDragNDropData ( mixed dragData [, material preview = nil, int previewColor = tocolor(255,255,255,255), float previewOffsetX = 0, float previewOffsetY = 0, float previewWidth = 20, float previewHeight = 20, string previewHorizontalAlign = "center", string previewVerticalAlign = "center" ] )

Required Arguments

  • dragData: Any type of data that you want to transfer.

Optional Arguments

  • preview: A material element that you want to demonstrate when dragging by the cursor.
  • previewColor: An integer of the color of preview you want. This can be converted by tocolor.
  • previewOffsetX: A float of the 2D x offset of the preview in pixels far from the cursor.
  • previewOffsetY: A float of the 2D y offset of the preview in pixels far from the cursor.
  • previewWidth: A float of the width in pixels of the preview.
  • previewHeight: A float of the height in pixels of the preview.
  • previewHorizontalAlign : A string indicates the horizontal alignment of the preview relative to the cursor. Available values are as follows:
    • left
    • center
    • right
  • previewVerticalAlign : A string indicates the vertical alignment of the preview relative to the cursor. Available values are as follows:
    • top
    • center
    • bottom

Returns

Returns true if successful, false otherwise

Example

local btn1 = dgsCreateButton(200,200,200,200,"SenderA",false)
local btn2 = dgsCreateButton(200,500,200,200,"SenderB",false)
local btn3 = dgsCreateButton(500,500,200,200,"Receiver",false)
addEventHandler("onDgsDrag",btn1,function(data)
	dgsSendDragNDropData({"From SenderA",getTickCount()})
end,false)
addEventHandler("onDgsDrag",btn2,function(data)
	dgsSendDragNDropData({"From SenderA",getTickCount()})
end,false)

addEventHandler("onDgsDrop",btn3,function(data)
	outputChatBox("Receive Data: "..inspect(data))
end,false)

See Also

Custom Cursor Functions

Multi Language Supports

Animation

3D Element

3D Interface

3D Line

3D Image

3D Text

Browser

Button

Check Box

Combo Box

Custom Renderer

Edit

Detect Area

Drag'N Drop

Grid List

Image

Memo

Menu

Label

Layout

Line

Progress Bar

Radio Button

Scale Pane

Scroll Bar

Scroll Pane

Selector

Style

Switch Button

Tab Panel

Window

Basic Shape Plugins

Circle

Quadrilateral

Rounded Rectangle

Other Plugins

Blur Box

Canvas

Chart

Color Picker

Effect 3D

Gradient

Mask

Media Browser

Nine Slice

Object Preview Supports

Paste Handler

QRCode

Remote Image

Screen Source

SVG

Tooltips