MCPcopy Create free account
hub / github.com/elastic/devfiler / clearable_line_edit

Function clearable_line_edit

src/ui/util.rs:26–43  ·  view source on GitHub ↗

Draw a line edit with a button for clearing it.

(ui: &mut Ui, hint: &str, input: &mut String)

Source from the content-addressed store, hash-verified

24
25/// Draw a line edit with a button for clearing it.
26pub fn clearable_line_edit(ui: &mut Ui, hint: &str, input: &mut String) {
27 let elem = TextEdit::singleline(input).hint_text(hint);
28 let edit_rect = ui.add(elem).rect;
29
30 if !input.is_empty() {
31 let mut clear_origin = edit_rect.right_center();
32 clear_origin.x -= 10.0;
33
34 let clear_rect = Rect::from_center_size(clear_origin, Vec2::splat(15.0));
35 let clear_widget = Button::new(icons::X).small().frame(false);
36
37 let clear_resp = ui.put(clear_rect, clear_widget);
38
39 if clear_resp.clicked() {
40 input.clear();
41 }
42 }
43}
44
45/// Draw a line edit with a button for clearing it and optional right-aligned text.
46pub fn clearable_line_edit_with_status(

Callers 2

updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected