1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Make the "tab-as-character" behaviour opt-in.

Added `tab_moves_focus()` to `TextEdit` so we can opt-in to the
"tab-as-character" behaviour.

Also because we decided to lock the tab size to 4 spaces, we gave
up on the `tab_size` property, but we kept the opt-in for the
"tab-as-spaces" behaviour.

An updated example of how to use `TextEdit` with those two opt-in
behaviours can be found in the "Misc Demos" demo.
This commit is contained in:
Cristian Dinu
2021-03-24 12:43:50 +02:00
parent 13ed86d932
commit 19e2608a56
3 changed files with 36 additions and 30 deletions

View File

@@ -25,6 +25,7 @@ pub struct Widgets {
single_line_text_input: String,
tab_size: usize,
tab_as_spaces: bool,
tab_moves_focus: bool,
multiline_text_input: String,
}
@@ -40,6 +41,7 @@ impl Default for Widgets {
tab_size: 4,
tab_as_spaces: true,
tab_moves_focus: false,
multiline_text_input: r#"Text can both be so wide that it needs a line break, but you can also add manual line break by pressing enter, creating new paragraphs.
This is the start of the next paragraph.
@@ -149,17 +151,14 @@ impl Widgets {
ui.separator();
ui.add(egui::Slider::usize(&mut self.tab_size, 2..=8).text("Tab size"));
ui.separator();
ui.checkbox(&mut self.tab_as_spaces, "Tabs as spaces");
ui.checkbox(&mut self.tab_moves_focus, "Tabs moves focus");
});
ui.add(
egui::TextEdit::multiline(&mut self.multiline_text_input)
.tab_as_spaces(self.tab_as_spaces)
.tab_size(self.tab_size),
.tab_moves_focus(self.tab_moves_focus)
.tab_as_spaces(self.tab_as_spaces),
);
}
}