I'm trying to execute an action (TakePhotoFromCameraAction) in a TActionList, when a TListViewItem is selected.
TlistView 和 TListViewItem 都没有 Action 属性,所以我尝试在事件中调用 ActionList[0].Execute ,但没有任何反应。
有任何想法吗?
进一步:代码非常简单,因为它只是对这个问题的测试。我专注于 ActionList,因为那是我将使用的(当我整理出来时)。Button1 不工作(它总是失败,即使按钮 2 不工作),而(新)Button2 工作正常。
type
TForm1 = class(TForm)
ActionList1: TActionList;
Memo1: TMemo;
TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
ActionList1[0].Execute;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if TakePhotoFromCameraAction1.Execute
then
Memo1.Lines.add('Photo OK')
else
Memo1.Lines.add('Photo Fail');
end;