Downstream and upstream

I’m making a UI system for fun, and I have run into a design problem.

My touch events are delivered downstream (Top most UI elements receive touches first), however my UI element visibility is going upstream (Setting bottom most UI element visible to false will hide all the elements it contains)

The problem is that I need to check if the UI element is visible when touch is received. Whats the approach you guys would take?

Perhaps take a look at the Android UI implementation for an idea. Specifically ViewGroup implementation which is the base class for layout components, IE ones that hold other UI components. The relevant method is “dispatchTouchEvent”

http://developer.android.com/reference/android/view/ViewGroup.html#dispatchTouchEvent(android.view.MotionEvent)

Events in the Android UI are passed from base parent to leaves and the entry point is dispatchTouchEvent. The cool thing is that you can do all sorts of interesting overriding of that method to provide custom event delivery.

Conceivably in you implementation you’d start at the root UI component with something like dispatchTouchEvent and if that root component was not visible you quit the dispatch. If the bounding box of the base UI component does not contain the event coordinates you quit, etc.

I think people should just ignore this thread. I’m kinda too tired and I didn’t realize that the solution was way too simple. There was no problem to begin with. I tripped here, because I wanted deliver events to all the views, but not call listeners if the view is not visible. I was just over thinking this :smiley: