vcl-dxai-1db3a025.md
A collection of AI-powered commands.
TdxAICommandList = class sealed(TObject)
The TdxAICommandList class implements a pre-populated list of AI-powered commands available in all supported native VCL controls. You can handle an OnGetAICommands event in any supported control to customize the list of available commands as demonstrated in code examples below.
A TdxAICommandList collection accessible through the AAICommands parameter within an OnGetAICommands event handler is populated with the following AI-powered command IDs (declared in the dxAI.Commands.Consts unit):
TdxAICommandIDs.ExpandExpands original text with additional information or in-depth explanations.TdxAICommandIDs.ShortenRemoves redundant details and makes content more concise.TdxAICommandIDs.SummarizeCreates a brief summary based on original text.TdxAICommandIDs.ExplainRephrases text in more clear terms and makes complex content more accessible and understandable.TdxAICommandIDs.ProofreadReviews text for spelling, grammar, punctuation, and style errors.TdxAICommandIDs.ChangeTone
The Change Tone command group is designed to adjust text tone to meet specific audience or context requirements. This group includes the following nested commands:
TdxAICommandIDs.ChangeTone.Professional)TdxAICommandIDs.ChangeTone.Casual)TdxAICommandIDs.ChangeTone.Straightforward)TdxAICommandIDs.ChangeTone.Confident)TdxAICommandIDs.ChangeTone.Friendly)TdxAICommandIDs.ChangeStyle
The Change Style command group is designed to rephrase or paraphrase original text while retaining its original meaning. This group includes the following nested commands:
TdxAICommandIDs.ChangeStyle.Formal)TdxAICommandIDs.ChangeStyle.Informal)TdxAICommandIDs.ChangeStyle.Technical)TdxAICommandIDs.ChangeStyle.Business)TdxAICommandIDs.ChangeStyle.Creative)TdxAICommandIDs.ChangeStyle.Journalistic)TdxAICommandIDs.ChangeStyle.Academic)TdxAICommandIDs.ChangeStyle.Persuasive)TdxAICommandIDs.ChangeStyle.Narrative)TdxAICommandIDs.ChangeStyle.Expository)TdxAICommandIDs.ChangeStyle.Descriptive)TdxAICommandIDs.ChangeStyle.Conversational)TdxAICommandIDs.Translate
The Translate command group is designed to translate original text into a different language. Includes the following nested commands that correspond to individual target languages:
TdxAICommandIDs.Translate.English)TdxAICommandIDs.Translate.German)TdxAICommandIDs.Translate.French)The list below outlines key members of the TdxAICommandList class. These members allow you to add/remove/rearrange individual end-user AI commands in the pre-populated list as well as change their status.
Add | Delete | RemoveAdd and remove individual commands.ClearClears the AI command collection.CountReturns the number of AI-powered commands in the collection.ExchangeSwaps two individual AI-powered commands.InsertInserts a new command at the target position.MoveMoves a command within the collection.
Specifies if an individual AI-powered command is available to users.
Tip
This property allows you to enable or disable UI elements and other options (such as dedicated keystrokes) associated with end-user AI commands.
Find | IndexOfReturn the index of the target command in the collection (-1 if no such command is present in the collection).
The following code example moves Explain and Proofread commands to the second and third positions in a context menu, respectively:
uses
dxRichEdit.Control, // Declares TdxRichEditControl
dxAI; // Declares AI-specific types
// ...
procedure TMyForm.dxRichEditControl1GetAICommands(Sender: TObject;
const AAICommands: TdxAICommandList);
var
ACommandIndex: Integer;
begin
ACommandIndex := AAICommands.IndexOf(TdxAICommandIDs.Explain);
AAICommands.Move(ACommandIndex, 1); // Moves "Explain" to the second position (after "Expand")
ACommandIndex := AAICommands.IndexOf(TdxAICommandIDs.Proofread);
AAICommands.Move(ACommandIndex, 2); // Moves "Proofread" to the third position (after "Explain")
end;
#include "dxRichEdit.Control.hpp" // Declares TdxRichEditControl
#include "dxAI.hpp" // Declares AI-specific types
// ...
void __fastcall TMyForm::dxRichEditControl1GetAICommands(TObject *Sender,
const TdxAICommandList *AAICommands)
{
int ACommandIndex = AAICommands->IndexOf(TdxAICommandIDs::Explain);
AAICommands->Move(ACommandIndex, 1); // Moves "Explain" to the second position (after "Expand")
ACommandIndex = AAICommands->IndexOf(TdxAICommandIDs::Proofread);
AAICommands->Move(ACommandIndex, 2); // Moves "Proofread" to the third position" (after "Explain")
}
The following code example hides all AI-powered commands (removes the AI Assistant item) when no content is selected in the document:
uses
dxRichEdit.Control, // Declares TdxRichEditControl
dxAI; // Declares AI-specific types
// ...
procedure TMyForm.dxRichEditControl1GetAICommands(Sender: TObject;
const AAICommands: TdxAICommandList);
begin
if ((Sender as TdxRichEditControl).Document.Selections.Count = 0) or
((Sender as TdxRichEditControl).Document.Selection.Length = 0) then
AAICommands.Clear;
end;
#include "dxRichEdit.Control.hpp" // Declares TdxRichEditControl
#include "dxAI.hpp" // Declares AI-specific types
// ...
void __fastcall TMyForm::dxRichEditControl1GetAICommands(TObject *Sender,
const TdxAICommandList *AAICommands)
{
if((dynamic_cast<TdxRichEditControl*>(Sender)->Document->Selections->Count == 0) ||
((dynamic_cast<TdxRichEditControl*>(Sender)->Document->Selection->Length == 0)))
AAICommands->Clear();
}
The following code example disables Expand , Shorten and Summarize commands in the context menu:
uses
dxRichEdit.Control, // Declares TdxRichEditControl
dxAI, // Declares AI-specific types
dxAI.Commands.Consts; // Declares AI command identifiers
// ...
procedure TMyForm.dxRichEditControl1GetAICommands(Sender: TObject;
const AAICommands: TdxAICommandList);
begin
AAICommands.Available[TdxAICommandIDs.Expand] := False;
AAICommands.Available[TdxAICommandIDs.Shorten] := False;
AAICommands.Available[TdxAICommandIDs.Summarize] := False;
end;
#include "dxRichEdit.Control.hpp" // Declares TdxRichEditControl
#include "dxAI.hpp" // Declares AI-specific types
#include "dxAI.Commands.Consts;" // Declares AI command identifiers
// ...
void __fastcall TMyForm::dxRichEditControl1GetAICommands(TObject *Sender,
const TdxAICommandList *AAICommands)
{
AAICommands->Available[TdxAICommandIDs::Expand] = false;
AAICommands->Available[TdxAICommandIDs::Shorten] = false;
AAICommands->Available[TdxAICommandIDs::Summarize] = false;
}
The TdxOnGetAICommands procedural type references a TdxAICommandList object as the AAICommands parameter.
TObject TdxAICommandList
See Also
TcxCustomTextEditProperties.OnGetAICommands Event