From 2d8ae7c9d0f230bcbd8ca812ed1c11d2815d512e Mon Sep 17 00:00:00 2001 From: tetenpapier Date: Thu, 11 Aug 2022 10:24:58 +0200 Subject: [PATCH] add new function in ui for textfilter and doc --- imgui/src/widget/text_filter.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/imgui/src/widget/text_filter.rs b/imgui/src/widget/text_filter.rs index 95d583b..eeac137 100644 --- a/imgui/src/widget/text_filter.rs +++ b/imgui/src/widget/text_filter.rs @@ -1,8 +1,8 @@ -//! Helper to parse and apply text filters use crate::sys; use crate::Ui; use std::ptr; +/// Helper to parse and apply text filters pub struct TextFilter { id: String, raw: *mut sys::ImGuiTextFilter, @@ -27,9 +27,9 @@ impl TextFilter { } /// Builds the TextFilter with its filter attribute. You can use - /// `[pass_filter()](Self::pass_filter)` after it. + /// [`pass_filter()`](Self::pass_filter) after it. /// - /// If you want control the filter with an InputText, check `[draw()](Self::draw)`. + /// If you want control the filter with an InputText, check [`draw()`](Self::draw). pub fn build(&self) { unsafe { sys::ImGuiTextFilter_Build(self.raw); @@ -61,6 +61,8 @@ impl TextFilter { } /// Returns true if the buffer matches the filter. + /// + /// [`draw()`](Self::draw) or [`build()`](Self::build) mut be called **before** this function. pub fn pass_filter(&self, mut buf: String) -> bool { buf.push('\0'); let ptr = buf.as_mut_ptr(); @@ -95,4 +97,8 @@ impl Ui { pub fn text_filter(label: String) -> TextFilter { TextFilter::new(label) } + + pub fn text_filter_with_filter(label: String, filter: String) -> TextFilter { + TextFilter::new_with_filter(label, filter) + } }