Popover
TsgcHTMLComponent_Popover — attach a Bootstrap 5 popover with a title and body to any trigger element, with configurable placement, trigger and dismiss behavior, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Popover — attach a Bootstrap 5 popover with a title and body to any trigger element, with configurable placement, trigger and dismiss behavior, in Delphi, C++ Builder and .NET.
A popover component that wraps a trigger element with Bootstrap 5 popover data attributes and an auto-init script. Set the content, title and body, then read the HTML property — or call the static Build helper for a one-liner.
TsgcHTMLComponent_Popover
Bootstrap 5 popover markup
Delphi, C++ Builder, .NET
Call BuildButton(text, title, body, style, placement) for a popover button, or create the component, set Placement and Trigger, then read HTML.
uses
sgcHTML_Enums, sgcHTML_Component_Popover;
// One-line static helper (primary form):
var
vHTML: string;
begin
vHTML := TsgcHTMLComponent_Popover.BuildButton('More info',
'Pricing', 'All licenses include full source code.',
bsPrimary, plTop);
WebModule.Response := vHTML;
end;
// Or configure it fully:
var
oPop: TsgcHTMLComponent_Popover;
begin
oPop := TsgcHTMLComponent_Popover.Create(nil);
try
oPop.Content := '<a href="#" class="btn btn-info">Details</a>';
oPop.Title := 'Shipping';
oPop.Body := 'Free delivery on orders over 50.';
oPop.Placement := plRight;
oPop.Trigger := ptHover;
oPop.Dismissible := True;
WebModule.Response := oPop.HTML; // trigger + popover init script
finally
oPop.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Popover.hpp
// One-line static helper (primary form):
String html = TsgcHTMLComponent_Popover::BuildButton("More info",
"Pricing", "All licenses include full source code.",
bsPrimary, plTop);
// Or configure it fully:
TsgcHTMLComponent_Popover *oPop = new TsgcHTMLComponent_Popover(NULL);
try
{
oPop->Content = "<a href=\"#\" class=\"btn btn-info\">Details</a>";
oPop->Title = "Shipping";
oPop->Body = "Free delivery on orders over 50.";
oPop->Placement = plRight;
oPop->Trigger = ptHover;
oPop->Dismissible = true;
String html = oPop->HTML; // trigger + popover init script
}
__finally
{
delete oPop;
}
using esegece.sgcWebSockets;
// One-line static helper (primary form):
string html = TsgcHTMLComponent_Popover.BuildButton("More info",
"Pricing", "All licenses include full source code.",
TsgcHTMLButtonStyle.bsPrimary, TsgcHTMLPlacement.plTop);
// Or configure it fully:
var pop = new TsgcHTMLComponent_Popover();
pop.Content = "<a href=\"#\" class=\"btn btn-info\">Details</a>";
pop.Title = "Shipping";
pop.Body = "Free delivery on orders over 50.";
pop.Placement = TsgcHTMLPlacement.plRight;
pop.Trigger = TsgcHTMLPopoverTrigger.ptHover;
pop.Dismissible = true;
string html = pop.HTML; // trigger + popover init script
The members you reach for most often.
Content is the trigger element's inner HTML; when empty, a styled button built from Title and ContentStyle is used instead.
Title sets the popover heading and Body its text (the Bootstrap data-bs-content).
Placement positions the popover with plTop, plBottom, plLeft or plRight via TsgcHTMLPlacement.
Trigger selects ptClick, ptHover, ptFocus or ptManual; Dismissible closes it on the next outside click.
AutoInit appends a script that calls new bootstrap.Popover for every popover; override the script via InitScript.
Build(content, title, body, placement, trigger) and BuildButton(text, title, body, style, placement) return ready markup; HTML emits the trigger plus its init script.