Add View::update which provides a ViewContext

This commit is contained in:
Nathan Sobo 2023-10-26 19:41:42 +02:00
parent 8e3314e680
commit a1c3826858
17 changed files with 403 additions and 247 deletions

View file

@ -1,7 +1,8 @@
use crate::{
point, px, view, Action, AnyBox, AnyDrag, AppContext, BorrowWindow, Bounds, Component,
point, px, Action, AnyBox, AnyDrag, AppContext, BorrowWindow, Bounds, Component,
DispatchContext, DispatchPhase, Element, ElementId, FocusHandle, KeyMatch, Keystroke,
Modifiers, Overflow, Pixels, Point, SharedString, Size, Style, StyleRefinement, ViewContext,
Modifiers, Overflow, Pixels, Point, SharedString, Size, Style, StyleRefinement, View,
ViewContext,
};
use collections::HashMap;
use derive_more::{Deref, DerefMut};
@ -332,7 +333,7 @@ pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {
Some(Box::new(move |view_state, cursor_offset, cx| {
let drag = listener(view_state, cx);
let drag_handle_view = Some(
view(cx.handle().upgrade().unwrap(), move |view_state, cx| {
View::for_handle(cx.handle().upgrade().unwrap(), move |view_state, cx| {
(drag.render_drag_handle)(view_state, cx)
})
.into_any(),