Toast
TsgcHTMLComponent_Toast — renderizza una notifica toast Bootstrap 5 con titolo, corpo, timestamp, colore e occultamento automatico, collocata sullo schermo da un contenitore posizionato, in Delphi, C++ Builder e .NET.
TsgcHTMLComponent_Toast — renderizza una notifica toast Bootstrap 5 con titolo, corpo, timestamp, colore e occultamento automatico, collocata sullo schermo da un contenitore posizionato, in Delphi, C++ Builder e .NET.
Un componente toast che emette markup toast Bootstrap 5. Imposta il titolo, il corpo e il colore, quindi leggi la proprietà HTML — oppure chiama l’helper statico Build e racchiudi i toast in un BuildContainer posizionato.
TsgcHTMLComponent_Toast
Bootstrap 5 toast markup
Delphi, C++ Builder, .NET
Chiama Build(title, body, color, timestamp) per un toast rapido e racchiudilo in BuildContainer(toasts, position), oppure crea il componente, imposta AutoHide e Delay, quindi leggi HTML.
uses
sgcHTML_Enums, sgcHTML_Component_Toast;
// One-line static helper (primary form):
var
vToast: string;
begin
vToast := TsgcHTMLComponent_Toast.Build('Saved',
'Your changes were stored.', hcSuccess, 'just now');
WebModule.Response := TsgcHTMLComponent_Toast.BuildContainer(vToast,
tpTopEnd);
end;
// Or configure it fully:
var
oToast: TsgcHTMLComponent_Toast;
begin
oToast := TsgcHTMLComponent_Toast.Create(nil);
try
oToast.ToastID := 'saveToast';
oToast.Title := 'Saved';
oToast.Body := 'Your changes were stored.';
oToast.ColorStyle := hcSuccess;
oToast.Timestamp := 'just now';
oToast.AutoHide := True;
oToast.Delay := 4000;
WebModule.Response := oToast.HTML; // Bootstrap toast markup
finally
oToast.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Toast.hpp
// One-line static helper (primary form):
String toast = TsgcHTMLComponent_Toast::Build("Saved",
"Your changes were stored.", hcSuccess, "just now");
String html = TsgcHTMLComponent_Toast::BuildContainer(toast, tpTopEnd);
// Or configure it fully:
TsgcHTMLComponent_Toast *oToast = new TsgcHTMLComponent_Toast(NULL);
try
{
oToast->ToastID = "saveToast";
oToast->Title = "Saved";
oToast->Body = "Your changes were stored.";
oToast->ColorStyle = hcSuccess;
oToast->Timestamp = "just now";
oToast->AutoHide = true;
oToast->Delay = 4000;
String body = oToast->HTML; // Bootstrap toast markup
}
__finally
{
delete oToast;
}
using esegece.sgcWebSockets;
// One-line static helper (primary form):
string toast = TsgcHTMLComponent_Toast.Build("Saved",
"Your changes were stored.", TsgcHTMLColor.hcSuccess, "just now");
string html = TsgcHTMLComponent_Toast.BuildContainer(toast,
TsgcHTMLToastPosition.tpTopEnd);
// Or configure it fully:
var t = new TsgcHTMLComponent_Toast();
t.ToastID = "saveToast";
t.Title = "Saved";
t.Body = "Your changes were stored.";
t.ColorStyle = TsgcHTMLColor.hcSuccess;
t.Timestamp = "just now";
t.AutoHide = true;
t.Delay = 4000;
string body = t.HTML; // Bootstrap toast markup
I membri che utilizzerai più spesso.
Title imposta il testo dell’intestazione, Body il messaggio, Timestamp la piccola etichetta dell’ora e Icon un’icona inline prima del titolo.
ColorStyle accetta un TsgcHTMLColor (come hcSuccess o hcDanger); Color accetta una stringa grezza con il nome di un colore Bootstrap.
AutoHide chiude il toast automaticamente dopo Delay millisecondi (predefinito 5000); imposta AutoHide a False per mantenerlo fisso.
ToastID assegna l’id dell’elemento così puoi mostrare o nascondere un toast specifico da JavaScript.
Build(title, body, color, timestamp) restituisce un toast; BuildContainer(toasts, position) li racchiude in un toast-container fisso (TsgcHTMLToastPosition).
HTML restituisce il markup completo del toast Bootstrap — servilo, oppure assegnalo al BodyContent di un template di pagina.