ChatBox

TsgcHTMLComponent_ChatBox — Delphi, C++ Builder 및 .NET에서 좌/우 메시지, 아바타, 입력 바 및 애니메이션 입력 중 표시기를 갖춘 카드 스타일의 채팅 말풍선 박스입니다.

TsgcHTMLComponent_ChatBox

스크롤 가능한 메시지 말풍선과 선택적 입력 바가 있는 Bootstrap 5 card를 내보내는 가벼운 채팅 컴포넌트입니다. 메시지를 추가하고, 몇 가지 속성을 설정한 다음, HTML 속성을 읽습니다.

컴포넌트 클래스

TsgcHTMLComponent_ChatBox

렌더링

Bootstrap 5 card + 범위 지정 CSS

패밀리

채팅 및 AI

언어

Delphi, C++ Builder, .NET

생성하고, 메시지를 추가하고, 렌더링하기

TitleHeight를 설정하고, AddMessage로 메시지 몇 개를 추가하고(caLeft 또는 caRight를 선택), HTML을 읽습니다(또는 TsgcHTMLTemplate_Bootstrap 페이지에 넣습니다).

uses
  sgcHTML_Enums, sgcHTML_Component_ChatBox;

var
  oChat: TsgcHTMLComponent_ChatBox;
begin
  oChat := TsgcHTMLComponent_ChatBox.Create(nil);
  try
    oChat.Title := 'Support';
    oChat.Height := '400px';
    oChat.ShowInput := True;
    oChat.InputPlaceholder := 'Type a message...';
    oChat.ShowTypingIndicator := True;

    oChat.AddMessage('Alice', 'Hi, how can I help?', caLeft, hcSecondary);
    oChat.AddMessage('You', 'My order has not arrived.', caRight, hcPrimary);

    WebModule.Response := oChat.HTML;   // Bootstrap card + chat bubbles
  finally
    oChat.Free;
  end;
end;

// Append a single new bubble (e.g. over a WebSocket push):
oChat.AddMessage('Alice', 'Let me check that for you.', caLeft);
WebSocket.WriteData(oChat.GetLastMessageHTML);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ChatBox.hpp

TsgcHTMLComponent_ChatBox *oChat = new TsgcHTMLComponent_ChatBox(NULL);
try
{
  oChat->Title = "Support";
  oChat->Height = "400px";
  oChat->ShowInput = true;
  oChat->InputPlaceholder = "Type a message...";
  oChat->ShowTypingIndicator = true;

  oChat->AddMessage("Alice", "Hi, how can I help?", caLeft, hcSecondary);
  oChat->AddMessage("You", "My order has not arrived.", caRight, hcPrimary);

  String html = oChat->HTML;   // Bootstrap card + chat bubbles
}
__finally
{
  delete oChat;
}
using esegece.sgcWebSockets;

var chat = new TsgcHTMLComponent_ChatBox();
chat.Title = "Support";
chat.Height = "400px";
chat.ShowInput = true;
chat.InputPlaceholder = "Type a message...";
chat.ShowTypingIndicator = true;

chat.AddMessage("Alice", "Hi, how can I help?", TsgcHTMLChatAlign.caLeft, TsgcHTMLColor.hcSecondary);
chat.AddMessage("You", "My order has not arrived.", TsgcHTMLChatAlign.caRight, TsgcHTMLColor.hcPrimary);

string html = chat.HTML;   // Bootstrap card + chat bubbles

주요 속성 및 메서드

가장 자주 사용하게 되는 멤버.

메시지

MessagesTsgcHTMLChatMessages 컬렉션입니다. 각 TsgcHTMLChatMessageSender, Text, Timestamp, Align(caLeft/caRight), ColorAvatarInitials를 담습니다.

메시지 추가

AddMessage(aSender, aText, aAlign, aColor, aTimestamp)는 말풍선을 추가합니다. 생략하면 아바타 이니셜과 시간이 자동으로 채워집니다.

입력 바

ShowInput은 폼을 토글합니다. InputPlaceholder, SendButtonTextSendButtonStyle(TsgcHTMLButtonStyle)이 작성기를 제어합니다.

헤더 및 입력 중

Title은 카드 헤더를 설정합니다. ShowTypingIndicator는 애니메이션 점을 표시하고 TypingText는 그 레이블을 설정합니다.

식별 및 크기

ChatID는 요소 id의 이름을 지정합니다. Height는 스크롤 영역의 경계를 정합니다(가장 최신 메시지로 자동 스크롤).

출력

HTML은 카드 전체를 반환합니다. GetLastMessageHTML은 가장 최근 말풍선만 반환합니다 — WebSocket으로 단일 업데이트를 푸시하는 데 이상적입니다.

계속 살펴보기

모든 sgcHTML 컴포넌트60개 이상의 컴포넌트 전체 기능 매트릭스를 둘러보십시오.
무료 체험판 다운로드30일 체험판에는 60.HTML 데모 프로젝트가 포함됩니다.
가격전체 소스 코드가 포함된 Single, Team 및 Site 라이선스.

시작할 준비가 되셨습니까?

무료 체험판을 다운로드하고 Delphi, C++ Builder 및 .NET에서 웹 UI를 구축하기 시작하십시오.