- Improve `Kbd::format` method.
- Add `tooltip_with_action` method to Button for display key binding in
tooltip.
-
## Break change
- The `Tooltip::new` has been changed it argument and return type.
```diff
- pub fn new(text: impl Into<Text>, _: &mut Window, cx: &mut App) ->
AnyView
+ pub fn new(text: impl Into<Text>) -> Self
```
40 lines
899 B
Rust
40 lines
899 B
Rust
use gpui::*;
|
|
use story::{Assets, TooltipStory};
|
|
|
|
pub struct Example {
|
|
root: Entity<TooltipStory>,
|
|
}
|
|
|
|
impl Example {
|
|
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
|
let root = TooltipStory::view(window, cx);
|
|
|
|
Self { root }
|
|
}
|
|
|
|
fn view(window: &mut Window, cx: &mut App) -> Entity<Self> {
|
|
cx.new(|cx| Self::new(window, cx))
|
|
}
|
|
}
|
|
|
|
impl Render for Example {
|
|
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
|
div()
|
|
.p_4()
|
|
.id("example")
|
|
.overflow_y_scroll()
|
|
.size_full()
|
|
.child(self.root.clone())
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let app = Application::new().with_assets(Assets);
|
|
|
|
app.run(move |cx| {
|
|
story::init(cx);
|
|
cx.activate(true);
|
|
|
|
story::create_new_window("Tooltip Example", Example::view, cx);
|
|
});
|
|
}
|