本文介绍了在DelphiXe4中拖放unicode TText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试用Delectangle& D在DelphiXE4中制作棋盘gui TText使用unicode棋子(请参阅 StackOverflow Delphi chess unicode链接拖放,但我无法让DND正常工作我的测试项目是FireMonkey FMX 我已经尝试过DragDrop / DragOver事件的各种代码添加,包括在代码中使用Accept& Source,但没有结果。 我将拖动器设置为TRectangle& TText组件的自动功能,可以获取拖动功能,但没有下拉功能!需要在事件中输入什么代码DragDrop DragOver on target TRectangle接受drop事件(我非常困惑,并且在任何地方找不到清楚的Google搜索指令!) 这是我的基本测试代码): unit Unit1; 界面 使用 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 {私人声明} public {公开声明} end; var Form1:TForm1; 实现 {$ R * .fmx} 程序TForm1.Rectangle7DragOver(发件人:TObject; const数据:TDragObject; const Point:TPointF; var Accept:Boolean); begin 如果发件人是TText然后接受:= True; 结束 结束。 非常感谢帮助&期待回复 - 谢谢 编辑/更新 这里是来自bummi的代码: $单位Unit3; b $ b unit Unit3; 接口 使用 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; 实现 {$ R * .fmx} 程序TForm3.Rectangle1DragOver(发件人:TObject; const数据:TDragObject; const点:TPointF; var接受:布尔); begin Caption:= Data.Source.ClassName; 接受:= Data.Source是TText; 结束结束。 然而即使这样,我仍然无法让我的象棋为我工作!哦,亲爱的aaargh!解决方案如果TDragObject的源是TText,那么你将不得不接受 接受:= Data.Source是TText; 发件人将是您的Rectangle7,或任何组件Rectangle7DragOver分配给。 I am trying to make a chessboard gui in DelphiXE4 with TRectangle & TText using unicode chess pieces (see StackOverflow Delphi chess unicode linkand 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;interfaceuses 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-thanksEDIT/UPDATEHere is code from bummi:unit Unit3;interfaceuses 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! 解决方案 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. 这篇关于在DelphiXe4中拖放unicode TText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 17:04