Struct dotrix_egui::CollapsingHeader [−][src]
pub struct CollapsingHeader { /* fields omitted */ }
Expand description
A header which can be collapsed/expanded, revealing a contained Ui
region.
egui::CollapsingHeader::new("Heading")
.show(ui, |ui| {
ui.label("Contents");
});
// Short version:
ui.collapsing("Heading", |ui| { ui.label("Contents"); });
Implementations
The CollapsingHeader
starts out collapsed unless you call default_open
.
The label is used as an Id
source.
If the label is unique and static this is fine,
but if it changes or there are several CollapsingHeader
with the same title
you need to provide a unique id source with Self::id_source
.
By default, the CollapsingHeader
is collapsed.
Call .default_open(true)
to change this.
Explicitly set the source of the Id
of this widget, instead of using title label.
This is useful if the title label is dynamic or not unique.
By default, the CollapsingHeader
text style is TextStyle::Button
.
Call .text_style(style)
to change this.
If you set this to false
, the CollapsingHeader
will be grayed out and un-clickable.
This is a convenience for Ui::set_enabled
.
Can the CollapsingHeader
be selected by clicking it? Default: false
.
If you set this to ‘true’, the CollapsingHeader
will be shown as selected.
Example:
let mut selected = false;
let response = egui::CollapsingHeader::new("Select and open me")
.selectable(true)
.selected(selected)
.show(ui, |ui| ui.label("Content"));
if response.header_response.clicked() {
selected = true;
}
Should the CollapsingHeader
show a background behind it? Default: false
.
To show it behind all CollapsingHeader
you can just use:
ui.visuals_mut().collapsing_header_frame = true;