[]Struct gtk::Button

pub struct Button(_, _);

The Button widget is generally used to trigger a callback function that is called when the button is pressed. The various signals and how to use them are outlined below.

The Button widget can hold any valid child widget. That is, it can hold almost any other standard Widget. The most commonly used child is the Label.

CSS nodes

Button has a single CSS node with name button. The node will get the style classes .image-button or .text-button, if the content is just an image or label, respectively. It may also receive the .flat style class.

Other style classes that are commonly used with Button include .suggested-action and .destructive-action. In special cases, buttons can be made round by adding the .circular style class.

Button-like widgets like ToggleButton, MenuButton, VolumeButton, LockButton, ColorButton, FontButton or FileChooserButton use style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file to differentiate themselves from a plain Button.

Implements

ButtonExt, BinExt, ContainerExt, WidgetExt, glib::object::ObjectExt, BuildableExt, ActionableExt, WidgetExtManual, BuildableExtManual

Methods

impl Button[src]

pub fn new() -> Button[src]

Creates a new Button widget. To add a child widget to the button, use ContainerExt::add.

Returns

The newly created Button widget.

pub fn new_from_icon_name(icon_name: Option<&str>, size: IconSize) -> Button[src]

Creates a new button containing an icon from the current icon theme.

If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.

This function is a convenience wrapper around Button::new and ButtonExt::set_image.

icon_name

an icon name or None

size

an icon size (IconSize)

Returns

a new Button displaying the themed icon

pub fn new_with_label(label: &str) -> Button[src]

Creates a Button widget with a Label child containing the given text.

label

The text you want the Label to hold.

Returns

The newly created Button widget.

pub fn new_with_mnemonic(label: &str) -> Button[src]

Creates a new Button containing a label. If characters in label are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.

label

The text of the button, with an underscore in front of the mnemonic character

Returns

a new Button

Trait Implementations

impl<T: ObjectType> PartialOrd<T> for Button

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for Button

impl<T: ObjectType> PartialEq<T> for Button

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Ord for Button

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Default for Button[src]

impl Clone for Button

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Hash for Button

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Display for Button[src]

impl Debug for Button

impl IsA<Bin> for Button

impl IsA<Container> for Button

impl IsA<Widget> for Button

impl IsA<Buildable> for Button

impl IsA<Actionable> for Button

impl IsA<Button> for CheckButton

impl IsA<Button> for ColorButton

impl IsA<Button> for FontButton

impl IsA<Button> for LinkButton

impl IsA<Button> for LockButton

impl IsA<Button> for MenuButton

impl IsA<Button> for ModelButton

impl IsA<Button> for RadioButton

impl IsA<Button> for ScaleButton

impl IsA<Button> for ToggleButton

impl IsA<Button> for VolumeButton

impl StaticType for Button

Auto Trait Implementations

impl Unpin for Button

impl !Sync for Button

impl !Send for Button

impl UnwindSafe for Button

impl RefUnwindSafe for Button

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> Cast for T where
    T: ObjectType

fn upcast<T>(self) -> T where
    Self: IsA<T>,
    T: ObjectType

Upcasts an object to a superclass or interface T. Read more

fn upcast_ref<T>(&self) -> &T where
    Self: IsA<T>,
    T: ObjectType

Upcasts an object to a reference of its superclass or interface T. Read more

fn downcast<T>(self) -> Result<T, Self> where
    Self: CanDowncast<T>,
    T: ObjectType

Tries to downcast to a subclass or interface implementor T. Read more

fn downcast_ref<T>(&self) -> Option<&T> where
    Self: CanDowncast<T>,
    T: ObjectType

Tries to downcast to a reference of its subclass or interface implementor T. Read more

fn dynamic_cast<T>(self) -> Result<T, Self> where
    T: ObjectType

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

fn dynamic_cast_ref<T>(&self) -> Option<&T> where
    T: ObjectType

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

unsafe fn unsafe_cast<T>(self) -> T where
    T: ObjectType

Casts to T unconditionally. Read more

unsafe fn unsafe_cast_ref<T>(&self) -> &T where
    T: ObjectType

Casts to &T unconditionally. Read more

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> ObjectExt for T where
    T: ObjectType

impl<T> ToValue for T where
    T: SetValue + ?Sized