Implement Selectable for buttons (#3451)

This PR implements the `Selectable` trait for `ButtonLike`, `Button`,
and `IconButton`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-11-29 18:46:41 -05:00 committed by GitHub
parent 481e42ade9
commit 9d53287341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 51 deletions

View file

@ -1,15 +1,7 @@
use gpui::{AnyView, WindowContext};
/// A trait for elements that can be selected.
pub trait Selectable {
/// Sets whether the element is selected.
fn selected(self, selected: bool) -> Self;
/// Sets the tooltip that should be shown when the element is selected.
fn selected_tooltip(
self,
tooltip: Box<dyn Fn(&mut WindowContext) -> AnyView + 'static>,
) -> Self;
}
#[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Copy)]