fix tui
This commit is contained in:
1 parent
608c37428d
commit
6c28de7d05
2 files changed
+3
-3
No files matched your search
@@ -10,7 +10,7 @@ fn main() {
|
|||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
let hue = use_state(cx, || 0.0);
|
let hue = use_state(cx, || 0.0);
|
||||||
let brightness = use_state(cx, || 0.0);
|
let brightness = use_state(cx, || 0.0);
|
||||||
let tui_query: &Query = cx.consume_context().unwrap();
|
let tui_query: Query = cx.consume_context().unwrap();
|
||||||
// disable templates so that every node has an id and can be queried
|
// disable templates so that every node has an id and can be queried
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
div{
|
div{
|
||||||
@@ -18,7 +18,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
background_color: "hsl({hue}, 70%, {brightness}%)",
|
background_color: "hsl({hue}, 70%, {brightness}%)",
|
||||||
onmousemove: move |evt| {
|
onmousemove: move |evt| {
|
||||||
if let RenderReturn::Sync(Some(node)) = cx.root_node() {
|
if let RenderReturn::Sync(Some(node)) = cx.root_node() {
|
||||||
if let Some(id) = node.root_ids[0].get() {
|
if let Some(id) = node.root_ids.get(0){
|
||||||
let node = tui_query.get(id);
|
let node = tui_query.get(id);
|
||||||
let Size{width, height} = node.size().unwrap();
|
let Size{width, height} = node.size().unwrap();
|
||||||
let pos = evt.inner().element_coordinates();
|
let pos = evt.inner().element_coordinates();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub use input::*;
|
|||||||
|
|
||||||
pub(crate) fn get_root_id<T>(cx: Scope<T>) -> Option<ElementId> {
|
pub(crate) fn get_root_id<T>(cx: Scope<T>) -> Option<ElementId> {
|
||||||
if let RenderReturn::Sync(Some(sync)) = cx.root_node() {
|
if let RenderReturn::Sync(Some(sync)) = cx.root_node() {
|
||||||
sync.root_ids.get(0).and_then(|id| id.get())
|
sync.root_ids.get(0)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user