Modal
TsgcHTMLComponent_Modal — renderuje modalne okno dialogowe Bootstrap 5 z tytułem, treścią, przyciskami stopki, rozmiarem oraz wyśrodkowanym lub statycznym tłem, w Delphi, C++ Builder i .NET.
TsgcHTMLComponent_Modal — renderuje modalne okno dialogowe Bootstrap 5 z tytułem, treścią, przyciskami stopki, rozmiarem oraz wyśrodkowanym lub statycznym tłem, w Delphi, C++ Builder i .NET.
Komponent modalnego okna dialogowego, który generuje znaczniki modal Bootstrap 5. Ustaw tytuł, treść i rozmiar, dodaj przyciski stopki, a następnie odczytaj właściwość HTML — albo wywołaj statyczną metodę pomocniczą Build dla jednolinijkowca.
TsgcHTMLComponent_Modal
Znaczniki modal Bootstrap 5
Delphi, C++ Builder, .NET
Wywołaj Build(id, title, body, footer, size) dla szybkiego okna modalnego albo utwórz komponent, dodaj przyciski stopki za pomocą AddFooterButton, a następnie odczytaj HTML. Połącz go z BuildTriggerButton, aby otworzyć okno dialogowe.
uses
sgcHTML_Enums, sgcHTML_Component_Modal;
// One-line static helper (primary form):
var
vTrigger, vDialog: string;
begin
vTrigger := TsgcHTMLComponent_Modal.BuildTriggerButton('confirmModal',
'Delete account', bsDanger);
vDialog := TsgcHTMLComponent_Modal.Build('confirmModal',
'Please confirm', 'This action cannot be undone.',
'', msDefault);
WebModule.Response := vTrigger + vDialog;
end;
// Or configure it fully and add custom footer buttons:
var
oModal: TsgcHTMLComponent_Modal;
begin
oModal := TsgcHTMLComponent_Modal.Create(nil);
try
oModal.ModalID := 'confirmModal';
oModal.Title := 'Please confirm';
oModal.Body := 'This action cannot be undone.';
oModal.Size := msLarge;
oModal.Centered := True;
oModal.StaticBackdrop := True;
oModal.AddFooterButton('Cancel', bsSecondary, True);
oModal.AddFooterButton('Delete', bsDanger);
WebModule.Response := oModal.HTML; // Bootstrap modal markup
finally
oModal.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Modal.hpp
// One-line static helper (primary form):
String trigger = TsgcHTMLComponent_Modal::BuildTriggerButton("confirmModal",
"Delete account", bsDanger);
String dialog = TsgcHTMLComponent_Modal::Build("confirmModal",
"Please confirm", "This action cannot be undone.",
"", msDefault);
// Or configure it fully and add custom footer buttons:
TsgcHTMLComponent_Modal *oModal = new TsgcHTMLComponent_Modal(NULL);
try
{
oModal->ModalID = "confirmModal";
oModal->Title = "Please confirm";
oModal->Body = "This action cannot be undone.";
oModal->Size = msLarge;
oModal->Centered = true;
oModal->StaticBackdrop = true;
oModal->AddFooterButton("Cancel", bsSecondary, true);
oModal->AddFooterButton("Delete", bsDanger);
String html = oModal->HTML; // Bootstrap modal markup
}
__finally
{
delete oModal;
}
using esegece.sgcWebSockets;
// One-line static helper (primary form):
string trigger = TsgcHTMLComponent_Modal.BuildTriggerButton("confirmModal",
"Delete account", TsgcHTMLButtonStyle.bsDanger);
string dialog = TsgcHTMLComponent_Modal.Build("confirmModal",
"Please confirm", "This action cannot be undone.",
"", TsgcHTMLModalSize.msDefault);
// Or configure it fully and add custom footer buttons:
var modal = new TsgcHTMLComponent_Modal();
modal.ModalID = "confirmModal";
modal.Title = "Please confirm";
modal.Body = "This action cannot be undone.";
modal.Size = TsgcHTMLModalSize.msLarge;
modal.Centered = true;
modal.StaticBackdrop = true;
modal.AddFooterButton("Cancel", TsgcHTMLButtonStyle.bsSecondary, true);
modal.AddFooterButton("Delete", TsgcHTMLButtonStyle.bsDanger);
string html = modal.HTML; // Bootstrap modal markup
Składniki, po które sięgasz najczęściej.
Title ustawia nagłówek, Body przechowuje treść okna dialogowego, a Footer przyjmuje surowy HTML stopki; ModalID to identyfikator elementu używany przez wyzwalacze.
AddFooterButton(text, style, closeOnClick) dołącza stylizowany przycisk; przekaż True dla closeOnClick, aby zamknąć okno modalne po kliknięciu.
Size wybiera msDefault, msSmall, msLarge, msXLarge lub msFullscreen za pomocą TsgcHTMLModalSize.
Centered wyśrodkowuje okno dialogowe w pionie, Scrollable przewija długą treść, StaticBackdrop blokuje zamknięcie po kliknięciu poza oknem, a ShowClose przełącza X w nagłówku.
Build(id, title, body, footer, size) zwraca gotowe okno modalne; BuildTriggerButton(modalID, text, style) generuje przycisk, który je otwiera.
HTML zwraca kompletne znaczniki okna modalnego Bootstrap — udostępnij je lub przypisz do właściwości BodyContent szablonu strony.