TdxOnGetAICommands Type
The procedural type for AI command list population events.
Declaration
TdxOnGetAICommands = procedure(Sender: TObject; const AAICommands: TdxAICommandList) of object;
Parameters
Name | Type | Description |
---|---|---|
Sender | TObject | Provides access to the control that raised the AI command list population event. You need to cast this parameter value to the corresponding terminal control class to access public API members. Tip Call the |
AAICommands | TdxAICommandList | Provides access to the pre-populated list of AI-powered end-user commands. Call Refer to the TdxAICommandList class description for detailed information on all available options (including the full list of predefined AI command IDs). |
Remarks
An AI command list population event occurs every time a supported control displays UI elements mapped to AI-powered end-user commands. You can handle these events to manage the list of available AI-powered commands and modify their status depending on specific conditions in your application.
Code Examples
Rearrange AI-Powered Commands
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;
Hide AI-Powered Commands
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;
Disable Individual AI-Powered Commands
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;
Related Compiled Demo
To see AI-powered commands in action, run the Word Processing RTF demo in the VCL Demo Center installed with compiled VCL DevExpress demos.
Select a text range, right-click within the control area, and expand the AI Assistant item to select the required command. The demo displays the result in a separate modal dialog:
The Word Processing RTF demo uses our Azure OpenAI Service deployment implemented as the TdxAIAzureChatClient
class. This class is declared in the dxAI.ChatClient.Azure.pas
unit shipped with demo source code.
Tip
You can find full source code for the installed Rich Edit control demo in the following folder:
%PUBLIC%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressRichEditControl
Direct TdxOnGetAICommands Type References
The following events reference the TdxOnGetAICommands
procedural type:
- TcxCustomTextEditProperties.OnGetAICommands
- Allows you to modify the list of AI-powered commands available in the editor.
- TdxRichEditControlBase.OnGetAICommands
- Allows you to modify the list of AI-powered commands available in the Rich Edit control.