Overwrite overlay method in Widget implementation for Button (#764)

* Overwrite `overlay` method in Widget implementation for Button

* Overwrite `overlay` method in Widget implementation for Button (cargo fmt)

* Fix button overlay
This commit is contained in:
Nicolas Levy 2021-03-14 23:39:01 +01:00 committed by GitHub
parent c1f70f1e92
commit 0333a8daff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
use crate::event::{self, Event}; use crate::event::{self, Event};
use crate::layout; use crate::layout;
use crate::mouse; use crate::mouse;
use crate::overlay;
use crate::touch; use crate::touch;
use crate::{ use crate::{
Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Widget, Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Widget,
@ -240,6 +241,13 @@ where
self.width.hash(state); self.width.hash(state);
self.content.hash_layout(state); self.content.hash_layout(state);
} }
fn overlay(
&mut self,
layout: Layout<'_>,
) -> Option<overlay::Element<'_, Message, Renderer>> {
self.content.overlay(layout.children().next().unwrap())
}
} }
/// The renderer of a [`Button`]. /// The renderer of a [`Button`].