Skip to main content

SearchCtrl

Struct SearchCtrl 

Source
pub struct SearchCtrl { /* private fields */ }
Expand description

Represents a wxSearchCtrl widget.

SearchCtrl uses WindowHandle internally for safe memory management. When the underlying window is destroyed (by calling destroy() or when its parent is destroyed), the handle becomes invalid and all operations become safe no-ops.

§Example

let search = SearchCtrl::builder(&frame).value("Search...").build();

// SearchCtrl is Copy - no clone needed for closures!
search.bind_search_button_clicked(move |_| {
    // Safe: if search was destroyed, this is a no-op
    let query = search.get_value();
    println!("Searching for: {}", query);
});

// After parent destruction, search operations are safe no-ops
frame.destroy();
assert!(!search.is_valid());

Implementations§

Source§

impl SearchCtrl

Source

pub fn builder(parent: &dyn WxWidget) -> SearchCtrlBuilder<'_>

Creates a new SearchCtrl builder.

Source

pub fn show_search_button(&self, show: bool)

Shows or hides the search button. No-op if the control has been destroyed.

Source

pub fn is_search_button_visible(&self) -> bool

Returns whether the search button is visible. Returns false if the control has been destroyed.

Source

pub fn show_cancel_button(&self, show: bool)

Shows or hides the cancel button. No-op if the control has been destroyed.

Source

pub fn is_cancel_button_visible(&self) -> bool

Returns whether the cancel button is visible. Returns false if the control has been destroyed.

Source

pub fn set_value(&self, value: &str)

Sets the text value of the control. No-op if the control has been destroyed.

Source

pub fn get_value(&self) -> String

Gets the current text value of the control. Returns empty string if the control has been destroyed.

Source

pub fn window_handle(&self) -> WindowHandle

Returns the underlying WindowHandle for this searchctrl.

Source§

impl SearchCtrl

Source

pub fn on_search_button_clicked<F>(&self, callback: F) -> EventToken
where F: FnMut(SearchCtrlEventData) + 'static,

Binds a handler to a widget-specific event. Returns an EventToken that can be used to unbind the handler later.

Source

pub fn on_cancel_button_clicked<F>(&self, callback: F) -> EventToken
where F: FnMut(SearchCtrlEventData) + 'static,

Binds a handler to a widget-specific event. Returns an EventToken that can be used to unbind the handler later.

Trait Implementations§

Source§

impl Clone for SearchCtrl

Source§

fn clone(&self) -> SearchCtrl

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SearchCtrl

Source§

impl FromWindowWithClassName for SearchCtrl

Source§

fn class_name() -> &'static str

Returns the expected wxWidgets class name for this widget type
Source§

unsafe fn from_ptr(ptr: *mut wxd_Window_t) -> Self

Safely construct this widget from a raw window pointer This should only be called after verifying the class name matches Read more
Source§

impl TextEvents for SearchCtrl

Source§

fn on_text_updated<F>(&self, callback: F) -> EventToken
where F: FnMut(TextEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_enter_pressed<F>(&self, callback: F) -> EventToken
where F: FnMut(TextEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

impl WindowEvents for SearchCtrl

Source§

fn on_mouse_left_down<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_left_up<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_right_down<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_right_up<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_middle_down<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_middle_up<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_motion<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_wheel<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_enter<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_mouse_leave<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_key_down<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_key_up<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_char<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_size<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_move_event<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_paint<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_erase_background<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_set_focus<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_kill_focus<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_activate<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_idle<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_close<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

fn on_destroy<F>(&self, callback: F) -> EventToken
where F: FnMut(WindowEventData) + 'static,

Binds a handler to a category-specific event. Returns an EventToken that can be used to unbind the handler later.
Source§

impl WxEvtHandler for SearchCtrl

Source§

unsafe fn get_event_handler_ptr(&self) -> *mut wxd_EvtHandler_t

Returns the raw event handler pointer for this widget. Read more
Source§

fn unbind(&self, token: EventToken) -> bool

Unbind a specific event handler by token. Read more
Source§

fn unbind_all(&self) -> usize

Unbind all event handlers currently attached to this handler. Read more
Source§

impl WxWidget for SearchCtrl

Source§

fn handle_ptr(&self) -> *mut wxd_Window_t

Returns the raw underlying window pointer. Unsafe because the lifetime is not tied to self. Primarily for internal use or passing back to FFI. Read more
Source§

fn is_valid(&self) -> bool

Check if this widget is still valid (not destroyed). Read more
Source§

fn get_id(&self) -> i32

Returns the window ID for this widget.
Source§

fn fit(&self)

Adjusts the window size to fit its contents or its sizer.
Source§

fn layout(&self)

Forces the window to recalculate its layout using its sizer. This is called when the window size changes to update the positions and sizes of child widgets according to the sizer constraints.
Source§

fn get_best_size(&self) -> Size

Gets the window’s sizer-calculated best size.
Source§

fn show(&self, show: bool)

Shows or hides the widget.
Source§

fn set_background_color(&self, color: Colour)

Sets the window’s background color.
Source§

fn set_background_style(&self, style: BackgroundStyle)

Sets the background style for the window. Read more
Source§

fn get_background_style(&self) -> BackgroundStyle

Gets the background style for the window.
Source§

fn set_min_size(&self, size: Size)

Sets the window’s minimum size.
Source§

fn refresh(&self, erase_background: bool, rect: Option<&Rect>)

Refreshes the window, optionally erasing the background and specifying a rectangle.
Source§

fn update(&self)

Repaints all invalid areas of the window immediately. Read more
Source§

fn set_tooltip(&self, tip: &str)

Sets the tooltip string for this widget.
Source§

fn destroy(&self)

Explicitly destroys the underlying wxWidgets object. After calling this, the widget wrapper should not be used further. This is useful for dynamically creating and destroying widgets.
Source§

fn set_font(&self, font: &Font)

Source§

fn get_font(&self) -> Option<Font>

Gets the font currently used for this widget. Read more
Source§

fn get_sizer(&self) -> Option<Sizer>

Gets the sizer currently assigned to this widget. Read more
Source§

fn set_sizer(&self, sizer: impl WxSizer, delete_old_sizer: bool)
where Self: Sized,

Sets the window’s sizer. Read more
Source§

fn set_sizer_and_fit(&self, sizer: impl WxSizer, delete_old_sizer: bool)
where Self: Sized,

Sets the window’s sizer and calls Fit() on the window. Read more
Source§

fn enable(&self, enable: bool)

Enables or disables the widget. Read more
Source§

fn is_enabled(&self) -> bool

Returns true if the widget is enabled, false otherwise.
Source§

fn get_position(&self) -> Point

Gets the window’s position relative to its parent.
Source§

fn get_size(&self) -> Size

Gets the window’s size.
Source§

fn set_size(&self, size: Size)

Sets the window’s size.
Source§

fn set_size_with_pos(&self, x: i32, y: i32, width: i32, height: i32)

Sets the window’s position and size.
Source§

fn set_client_size(&self, size: Size)

Sets the window’s client area size (the area inside borders, scrollbars, etc).
Source§

fn get_client_size(&self) -> Size

Gets the client area size.
Source§

fn get_min_size(&self) -> Size

Gets the window’s minimum size.
Source§

fn move_window(&self, x: i32, y: i32)

Moves the window to the specified position.
Source§

fn center(&self)

Centers the window relative to its parent.
Source§

fn centre(&self)

UK spelling alias for center()
Source§

fn client_to_screen(&self, pt: Point) -> Point

Converts client coordinates to screen coordinates.
Source§

fn screen_to_client(&self, pt: Point) -> Point

Converts screen coordinates to client coordinates.
Source§

fn get_label(&self) -> Option<String>

Gets the window label (title or text). Returns None if the label is not set, cannot be converted to UTF-8, or an error occurs.
Source§

fn set_label(&self, label: &str)

Sets the window label (title or text). Read more
Source§

fn set_extra_style(&self, extra_style: ExtraWindowStyle)

Sets the extra window style flags. Read more
Source§

fn set_extra_style_raw(&self, extra_style: i64)

Sets extra window style flags using raw i64 value. Read more
Source§

fn get_extra_style_raw(&self) -> i64

Gets the current extra window style flags as raw value. Read more
Source§

fn has_extra_style(&self, style: ExtraWindowStyle) -> bool

Checks if a specific extra window style flag is set. Read more
Source§

fn add_extra_style(&self, style: ExtraWindowStyle)

Adds extra window style flags to the current set. Read more
Source§

fn remove_extra_style(&self, style: ExtraWindowStyle)

Removes extra window style flags from the current set. Read more
Source§

fn get_parent(&self) -> Option<Window>

Gets the parent window of this widget. Read more
Source§

fn set_foreground_color(&self, color: Colour)

Sets the foreground color of the window. Read more
Source§

fn get_foreground_color(&self) -> Colour

Gets the foreground color of the window. Read more
Source§

fn get_background_color(&self) -> Colour

Gets the background color of the window. Read more
Source§

fn set_focus(&self)

Sets the focus to this window. Read more
Source§

fn has_focus(&self) -> bool

Returns true if this window currently has focus.
Source§

fn can_accept_focus(&self) -> bool

Returns true if this window can accept focus. Read more
Source§

fn accepts_focus_from_keyboard(&self) -> bool

Returns true if this window accepts focus from keyboard navigation. Read more
Source§

fn set_can_focus(&self, can_focus: bool)

Sets whether this window can accept focus. Read more
Source§

fn is_shown(&self) -> bool

Returns true if the window is currently shown. Read more
Source§

fn hide(&self)

Hides the window. Read more
Source§

fn set_max_size(&self, size: Size)

Sets the maximum size for the window. Read more
Source§

fn get_max_size(&self) -> Size

Gets the maximum size for the window. Read more
Source§

fn set_name(&self, name: &str)

Sets the window name. Read more
Source§

fn get_name(&self) -> String

Gets the window name. Read more
Source§

fn close(&self, force: bool) -> bool

Attempts to close the window. Read more
Source§

fn find_window_by_name(&self, name: &str) -> Option<Window>

Finds a child window by name. Read more
Source§

fn find_window_by_id(&self, id: i32) -> Option<Window>

Finds a child window by ID. Read more
Source§

fn set_cursor(&self, cursor: Option<&Cursor>)

Sets the cursor for this window. Read more
Source§

fn get_cursor(&self) -> Option<Cursor>

Gets the cursor currently associated with this window. Read more
Source§

fn raise(&self)

Raises the window to the top of the window hierarchy (Z-order). Read more
Source§

fn lower(&self)

Lowers the window to the bottom of the window hierarchy (Z-order). Read more
Source§

fn capture_mouse(&self)

Directs all mouse input to this window. Read more
Source§

fn release_mouse(&self)

Releases mouse capture. Read more
Source§

fn has_capture(&self) -> bool

Returns true if this window currently has mouse capture.
Source§

fn get_capture() -> Option<Window>
where Self: Sized,

Returns the window that currently has mouse capture. Read more
Source§

fn freeze(&self)

Freeze the window: don’t redraw it until it is thawed
Source§

fn thaw(&self)

Thaw the window: redraw it after it had been frozen
Source§

fn is_frozen(&self) -> bool

Return true if window had been frozen and not unthawed yet
Source§

fn get_text_extent(&self, text: &str) -> Size

Gets the dimensions of the string as it would be drawn on the window with the currently selected font. Read more
Source§

fn get_full_text_extent( &self, text: &str, font: Option<&Font>, ) -> (Size, i32, i32)

Gets the full dimensions of the string as it would be drawn on the window. Read more
Source§

fn get_char_height(&self) -> i32

Returns the character height for this window using the current font. Read more
Source§

fn get_char_width(&self) -> i32

Returns the average character width for this window using the current font. Read more
Source§

fn set_style(&self, style: WindowStyle)

Sets the window style flags. Read more
Source§

fn set_style_raw(&self, style: i64)

Sets window style flags using raw i64 value. Read more
Source§

fn get_style_raw(&self) -> i64

Gets the current window style flags as raw value. Read more
Source§

fn has_style(&self, style: WindowStyle) -> bool

Checks if a specific window style flag is set. Read more
Source§

fn add_style(&self, style: WindowStyle)

Adds window style flags to the current set. Read more
Source§

fn remove_style(&self, style: WindowStyle)

Removes window style flags from the current set. Read more
Source§

fn get_handle(&self) -> *mut c_void

Gets the native handle of the window (platform-specific). Read more
Source§

fn move_after_in_tab_order(&self, win: &dyn WxWidget)

Moves this window to appear after the specified window in the tab order. Read more
Source§

fn move_before_in_tab_order(&self, win: &dyn WxWidget)

Moves this window to appear before the specified window in the tab order. Read more
Source§

fn get_next_sibling(&self) -> Option<Window>

Gets the next sibling window in the parent’s child list. Read more
Source§

fn get_prev_sibling(&self) -> Option<Window>

Gets the previous sibling window in the parent’s child list. Read more
Source§

fn navigate(&self, forward: bool) -> bool

Navigates to the next or previous control. Read more
Source§

fn popup_menu(&self, menu: &mut Menu, screen_pos: Option<Point>) -> bool

Shows a popup menu at the specified position or at the current mouse position. Read more
Source§

fn process_menu_command(&self, id: i32) -> bool

Synchronously dispatch a wxEVT_MENU with the given command ID to this window. Returns true if any handler processed the event.
Source§

fn post_menu_command(&self, id: i32)

Asynchronously post a wxEVT_MENU with the given command ID to this window. The event will be queued and delivered later by the main loop.
Source§

fn set_accessible(&self, accessible: Accessible)

Sets the accessible object for this window. Read more
Source§

fn get_accessible(&self) -> Option<Accessible>

Gets the accessible object for this window. Read more
Source§

impl XrcSupport for SearchCtrl

Available on crate feature xrc only.
Source§

unsafe fn from_xrc_ptr(ptr: *mut wxd_Window_t) -> Self

Creates a widget wrapper for an XRC-managed object. This widget will not be destroyed when dropped as it’s managed by XRC. Each widget implements this with their specific field structure. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromXrcPtr for T
where T: XrcSupport,

Source§

type RawFfiType = *mut wxd_Window_t

Source§

unsafe fn from_xrc_ptr(ptr: <T as FromXrcPtr>::RawFfiType) -> T

Create a widget wrapper from an XRC-managed pointer The widget does not own the pointer - XRC manages its lifetime Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<W> WindowXrcMethods for W
where W: WxWidget,

Source§

fn find_child_by_xrc_name<T: FromXrcPtr<RawFfiType = *mut wxd_Window_t> + WxWidget>( &self, name: &str, ) -> Option<T>

Find a child window by XRC name
Source§

impl<W> WxWidgetDowncast for W
where W: WxWidget + Any,

Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: WxWidget + 'static,

Attempts to downcast this widget to a specific type. Returns Some(&T) if the widget is of type T, None otherwise.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: WxWidget + 'static,

Attempts to downcast this widget to a specific type (mutable). Returns Some(&mut T) if the widget is of type T, None otherwise.
Source§

fn widget_type_name(&self) -> &'static str

Returns the type name of this widget for debugging purposes.