Skip to main content
All docs
V25.1
  • 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 Sender.ClassType function or use other RTTI functionality to identify the actual control class.

    AAICommands TdxAICommandList

    Provides access to the pre-populated list of AI-powered end-user commands.

    Call AAICommands.Add or AAICommands.Remove procedures to add or remove individual commands. To enable or disable UI elements associated with corresponding commands, use the AAICommands.Available property.

    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;
    

    VCL Shared Libraries: Rearranged AI-Powered Commands in a Context Menu

    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;
    

    VCL Rich Edit: The Context Menu Without AI-Powered Commands

    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;
    

    VCL Rich Edit: Individual Disabled AI-Powered Commands

    To see AI-powered commands in action, run the Word Processing RTF demo in the VCL Demo Center installed with compiled VCL DevExpress demos.

    VCL Rich Edit: AI-Powered Commands

    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:

    VCL Rich Edit: A Translation Result Example

    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.

    Download: Compiled VCL Demos

    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.
    See Also