How to make widget block Line Trace?

I am working on an APP to change material of the wall and floor. So almost every mesh in the level can be selected and changed.

In the level, I use LineTrace to hit/select objects. If any/floor wall is selected, a widget with buttons for materials to show up. My problem is: if the button in this widget is clicked, the wall behind the widget is also selected. And I don’t want to use SetInputModeUIOnly, because I still want to select the wall which is not behind the widget.

In other words: I want to enable the selection of the wall which is not behind the widget, and disable the selection of the wall which is behind the widget.

How can I do that? Is there anyway to let the widget “block” the Line Trace?

I used a workaround to solve this problem.

IF the widget is visible {
    IF the touch location X and Y are within the widget {
        do LineTrace to hit the StaticMeshes