You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each time when I want to do some complex things with input bubbling its just freaking me out how conceptually dirty input system is.
Main conflict is that we need to read input beforehand, and draw after. But there are many situations when you simple cant do this because that is how immediate mode works or its because egui does not handle this states.
Imagine I have panel, and button in there. I want to distinguish - when my button hovered, parent should be not hovered. I know its a kind of feature to hover all parents, but what if ? I dont get idiomatic way to do that.
I can ignore Response stuff and check raw input, knowing all my layout before painting.
I can save that there is something hovered, and read this next frame, and introduce some frame lag.
I can PR something with "Add hovered_topmost" in Memory (if there is no one) (btw this is done with Windows, as far as I researched when I write this post)
You can say - But Windows/Areas works just great. And that's the problem. Areas is a huge hacky machinery to simulate retained mode. There are dozens of mechanics exists in a big, scattered parts of code, which is not documented. You can find in in Memory, Areas types. All this hack: things.
// HACK: windows have low priority on dragging.
// This is so that if you drag a slider in a window,
// the slider will steal the drag away from the window.
// This is needed because we do window interaction first (to prevent frame delay),
// and then do content layout.
Common pattern I learned - is to delay component contents render by passing lambda, so the flow is right what i said earlier:
check input before lambda
draw window?
draw lambda
place response in InnerResponse and return it.
So, what if my component background depends on what i draw in component contents?
PS: Sad code samples.
Here is just a few (temporary i guess) hacks.
First sign that there is something wrong with event bubbling. But its okay, b/c hopefully I can read scroll right from context or so.
// Clear scroll delta so no parent scroll will use it.
frame_state.scroll_delta[d] = 0.0;
Here is another one:
response.hovered &= response.is_pointer_button_down_on; // we don't hover widgets while interacting with *other* widgets
So the only thing that stops any other widgets from being hovered is pressed button. Strictly speaking there is one thing that protect egui from pass click event to the parent widgets - its memory.interaction.click_id
Almost everything interact do is
check rect.contains
save click_id
So. many things become clear for me while i Write this post. But nevertheless immidiate mode is not so simple as it tries to be.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Each time when I want to do some complex things with input bubbling its just freaking me out how conceptually dirty input system is.
Main conflict is that we need to read input beforehand, and draw after. But there are many situations when you simple cant do this because that is how immediate mode works or its because egui does not handle this states.
Imagine I have panel, and button in there. I want to distinguish - when my button hovered, parent should be not hovered. I know its a kind of feature to hover all parents, but what if ? I dont get idiomatic way to do that.
You can say - But Windows/Areas works just great. And that's the problem. Areas is a huge hacky machinery to simulate retained mode. There are dozens of mechanics exists in a big, scattered parts of code, which is not documented. You can find in in Memory, Areas types. All this
hack:
things.Common pattern I learned - is to delay component contents render by passing lambda, so the flow is right what i said earlier:
So, what if my component background depends on what i draw in component contents?
PS: Sad code samples.
Here is just a few (temporary i guess) hacks.
First sign that there is something wrong with event bubbling. But its okay, b/c hopefully I can read scroll right from context or so.
Here is another one:
So the only thing that stops any other widgets from being hovered is pressed button. Strictly speaking there is one thing that protect egui from pass click event to the parent widgets - its
memory.interaction.click_id
Almost everything
interact
do isrect.contains
So. many things become clear for me while i Write this post. But nevertheless immidiate mode is not so simple as it tries to be.
Cheers.
Beta Was this translation helpful? Give feedback.
All reactions