ferroui_controls/auto_complete_box/populating_event_args.rs
1// (c) Copyright Microsoft Corporation.
2// This source is subject to the Microsoft Public License (Ms-PL).
3// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
4// All other rights reserved.
5//
6// Ported from the Silverlight Toolkit sources as adapted by the upstream
7// project; the license text is in the `NOTICE.md` of this crate.
8
9use ferroui_base::utilities::CancelEventArgs;
10use std::ops::Deref;
11
12/// Provides data for the `Populating` event of the
13/// [`AutoCompleteBox`](super::AutoCompleteBox).
14///
15/// A copy shares the cancel flag of the args it was made from.
16#[derive(Clone, PartialEq)]
17pub struct PopulatingEventArgs {
18 base: CancelEventArgs,
19 parameter: Option<String>,
20}
21
22impl PopulatingEventArgs {
23 /// Initializes a new instance of the [`PopulatingEventArgs`].
24 ///
25 /// `parameter` is the value of the `SearchText` property, which is
26 /// used to filter items for the control.
27 pub fn new(parameter: Option<String>) -> Self {
28 Self { base: CancelEventArgs::new(), parameter }
29 }
30
31 /// Gets the text that is used to determine which items to display in
32 /// the control.
33 pub fn parameter(&self) -> Option<&str> {
34 self.parameter.as_deref()
35 }
36}
37
38impl Deref for PopulatingEventArgs {
39 type Target = CancelEventArgs;
40
41 fn deref(&self) -> &CancelEventArgs {
42 &self.base
43 }
44}