fdragndrop.class

来自「Gambas is a graphical development enviro」· CLASS 代码 · 共 90 行

CLASS
90
字号
' Gambas class filePRIVATE $iKey AS IntegerPRIVATE CONST MIME_TYPE AS String = "text/x-gambas-dragndrop-example"PUBLIC SUB imgIcon_MouseMove()  IF Mouse.Left THEN    Drag.Icon = LAST.Picture    LAST.Drag(LAST.Picture.Image)  ENDIFEND' PUBLIC SUB TreeView1_Drag()''   IF Drag.Type <> Drag.Image THEN STOP EVENT'' ENDPUBLIC SUB TreeView1_DragMove()  IF Drag.Type <> Drag.Image THEN STOP EVENTENDPUBLIC SUB TreeView1_Drop()  DIM sKey AS String  WITH TreeView1    IF NOT .Find(Drag.X, Drag.Y) THEN      sKey = .Item.Key    ENDIF    INC $iKey    .Add($iKey, "#" & $iKey, Drag.Data.Picture, sKey).EnsureVisible  END WITHENDPUBLIC SUB TreeView1_MouseMove()  DIM hPict AS Picture  IF NOT Mouse.Left THEN RETURN  WITH TreeView1    IF .Find(Mouse.X, Mouse.Y) THEN RETURN    IF NOT .Key THEN RETURN    hPict = NEW Picture(32 + 8 + .Font.Width(.Current.Text), 32, TRUE)    Draw.Begin(hPict)      Draw.Picture(.Current.Picture, 0, 0)      Draw.Font = .Font      Draw.Text(.Current.Text, 34, 0, hPict.Width, 32, Align.Left)    Draw.End    Drag.Icon = hPict    .Drag(.Key, MIME_TYPE)  END WITHENDPUBLIC SUB imgHole_Drag()  IF Drag.Type = Drag.Text THEN    IF Drag.Format = MIME_TYPE THEN      RETURN    ENDIF  ENDIF  STOP EVENTENDPUBLIC SUB imgHole_Drop()  TreeView1.Remove(Drag.Data)ENDPUBLIC SUB Form_Open()  ME.CenterEND

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?