Give the MouseEventHandlers for each tab bar their own id

This fixes a beachball where we oscillate back and forth between hovered and unhovered due to confusing two different tab bars as the same tab bar.
This commit is contained in:
Nathan Sobo 2021-11-03 16:15:41 -06:00
parent 595dbd44ae
commit 0ff87e603f
2 changed files with 5 additions and 1 deletions

View File

@ -2418,6 +2418,10 @@ impl<'a, T: View> RenderContext<'a, T> {
pub fn handle(&self) -> WeakViewHandle<T> {
WeakViewHandle::new(self.window_id, self.view_id)
}
pub fn view_id(&self) -> usize {
self.view_id
}
}
impl AsRef<AppContext> for &AppContext {

View File

@ -182,7 +182,7 @@ impl Pane {
let theme = &settings.theme;
enum Tabs {}
let tabs = MouseEventHandler::new::<Tabs, _, _, _>(0, cx, |mouse_state, cx| {
let tabs = MouseEventHandler::new::<Tabs, _, _, _>(cx.view_id(), cx, |mouse_state, cx| {
let mut row = Flex::row();
for (ix, item) in self.items.iter().enumerate() {
let is_active = ix == self.active_item;