NG Drag&Drop Guide


TNGUnicodeTextFormat


TNGUnicodeTextFormat class implements standard CF_UNICODETEXT data format and allows to drag/receive Unicode text data. NG Drag&Drop use string standard Delphi type for working with Unicode text data.

 

The class declares two methods: Data and Ref. Data method can be used to drag text data at the source side, while Ref method can be used to receive text data at the target side. NG Drag&Drop declares special type alias CF.UNICODETEXT to make user's code more readable:

 

NGDropSource.Add(CF.UNICODETEXT.Data('My dragging text'))

            .Execute;

 

NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)

var

  s: string;

begin

  if C.Accept(CF.UNICODETEXT.Ref(@s)) then

    Edit1.Text := s;

end);

 

Moreover, special methods are declared for working with text data, which can simplify code even more:

 

NGDropSource.AddUnicodeText('My dragging text')

            .Execute;

 

NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)

var

  s: string;

begin

  if C.AcceptUnicodeText(@s) then

    Edit1.Text := s;

end);