Skip to content

recursive widget #917

Answered by BctfN0HUK7Yg
BctfN0HUK7Yg asked this question in Q&A
Nov 29, 2021 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

ok, I solve it.

if depth > 0 {
let child_rect = rect.shrink2(egui::vec2(200.0, 50.0));

    let child_response = ui.put(child_rect, block(depth - 1, state));

    if child_response.hovered() || child_response.changed() {
        child_hovered = true;
    }
}

if child_hovered {
    response = ui.allocate_rect(egui::Rect::NOTHING, egui::Sense::click_and_drag());
    response.mark_changed();
} else {
    response = ui.allocate_rect(rect, egui::Sense::click_and_drag());
}

May be it isn't best way, but it works

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@emilk
Comment options

@yasn0st
Comment options

@BctfN0HUK7Yg
Comment options

@BctfN0HUK7Yg
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by BctfN0HUK7Yg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants