63625

Drag and drop unicode TText in DelphiXe4

Question:

I am trying to make a chessboard gui in DelphiXE4 with TRectangle & TText using unicode chess pieces (see <a href="https://stackoverflow.com/questions/17189143/unicode-in-delphi-form-trectangle-ttext?noredirect=1#comment24892586_17189143" rel="nofollow">StackOverflow Delphi chess unicode link</a>and drag and drop but I cannot get DND to work properly! My test project is FireMonkey FMX. I have tried various code additions to DragDrop/DragOver Events including using Accept & Source in code but to no result.

I set dragdrop to auto on TRectangle & TText components & can get drag function but no drop function! What code do I need to enter in Events DragDrop DragOver on target TRectangle to accept the drop event? (I am very confused with this & cannot find clear instruction on Google search anywhere!)

Here is my basic test code (on Form):

unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Objects; type TForm1 = class(TForm) Rectangle1: TRectangle; Rectangle2: TRectangle; Rectangle3: TRectangle; Rectangle4: TRectangle; Rectangle5: TRectangle; Rectangle6: TRectangle; Rectangle7: TRectangle; Rectangle8: TRectangle; Rectangle9: TRectangle; Text1: TText; procedure Rectangle7DragOver(Sender: TObject; const Data: TDragObject; const Point: TPointF; var Accept: Boolean); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.Rectangle7DragOver(Sender: TObject; const Data: TDragObject; const Point: TPointF; var Accept: Boolean); begin if Sender is TText then Accept := True; end; end.

Most grateful for help & look forward to replies-thanks

EDIT/UPDATE

Here is code from bummi:

unit Unit3; interface uses System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Objects, FMX.Edit; type TForm3 = class(TForm) Rectangle1: TRectangle; Text1: TText; Edit1: TEdit; procedure Rectangle1DragOver(Sender: TObject; const Data: TDragObject; const Point: TPointF; var Accept: Boolean); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form3: TForm3; implementation {$R *.fmx} procedure TForm3.Rectangle1DragOver(Sender: TObject; const Data: TDragObject; const Point: TPointF; var Accept: Boolean); begin Caption := Data.Source.ClassName ; Accept := Data.Source is TText; end; end.

However even with this I still cannot get my chess example to work for me! Oh dear aaargh!

Answer1:

You will have to Accept if the Source of then TDragObject is TText.

Accept := Data.Source is TText;

Sender would be your Rectangle7, or any component Rectangle7DragOver is assigned to.

Recommend

  • The same file on host and inside container is different, it is not in sync with its original
  • In Kotlin, Jackson Deserialization error with data class
  • Number data type showing up as # in SQL Plus
  • Webpack dynamic import method returns empty array instead of files in reactjs, How to solve?
  • addition of date in sql function
  • How do I replace 'php3' with 'php' inside every file in a directory
  • Moving Circle on Live Wallpaper
  • How to upload an Image onto localhost server whilst path is stored in mysql database?
  • wxpython passing information, pointers?
  • How to read contents of a directory recursively in Linux Kernel?
  • Winston logger not write to file
  • Background beacon detection and Notification (Both iOS and Android) for Eddystone beacon?
  • Azure NodeJS Error: ENOENT, open 'D:\\home\\site\\wwwroot\\bin\\views\\'
  • why 'read' command in shell script is missing initial characters? [duplicate]
  • Laravel 5 - Cache remember doesn't work
  • VB.NET and LINQ - Group by in a DataTable
  • How to get a time and Date Separately?
  • Extracting a small subset of data from XMLs
  • separate tokens in batch file
  • “Cannot open log for source” - Windows 7 - .NET web service - event log
  • Building JavaFX 2.0 App on Mac, deploying on Windows
  • How to use Flask's render_template from an ajax POST form submit
  • Generate and export point cloud from Project Tango
  • how to specify different css for ie
  • When to use the tag in the head and body section of a html page? [duplicate]
  • How to use Kaminari pagination gem with Sinatra and Mongoid?
  • Runtime complexity of getting the length of a string in different representations
  • I am consuming a WCF service that requires headers from a .NET 2 website. How can I programmatically
  • JavaScript Regex to Match Boundaries of Words with diacritics
  • Apple Mach-O Linker error (“duplicate symbol”)
  • How to get rgb from transparent pixel in js
  • ssh remote server login script
  • Computing the discrete fourier transform of audio data with FFTW
  • Make checkout phone field optional for specific countries in WooCommerce
  • calling IO Operations from thread in ruby c extension will cause ruby to hang
  • Angular 4: Responsive Grid List
  • Angular FormGroup won't update it's value immediately after patchValue or setValue
  • Write to .csv file with PHP (Commas in Data Error)