Fix #147282: double clicking on value enters node group

This fix makes the enter-node-group operator pass through when interacting with a button.

The code is by @JulianEisel.

Pull Request: https://projects.blender.org/blender/blender/pulls/148133
This commit is contained in:
Jacques Lucke
2025-10-16 19:21:12 +02:00
parent 7075bbc176
commit 04fcc4126e
6 changed files with 19 additions and 8 deletions

View File

@@ -726,6 +726,13 @@ bool UI_block_can_add_separator(const uiBlock *block);
*/
bool UI_block_has_active_default_button(const uiBlock *block);
/**
* Find a button under the mouse cursor, ignoring non-interactive ones (like labels). Holding Ctrl
* over a label button that can be Ctrl-Clicked to turn into an edit button will return that.
* Labels that are only interactive for the sake of displaying a tooltip are ignored too.
*/
uiBut *UI_but_find_mouse_over(const ARegion *region, const wmEvent *event) ATTR_WARN_UNUSED_RESULT;
uiList *UI_list_find_mouse_over(const ARegion *region, const wmEvent *event);
/* `interface_region_menu_popup.cc` */

View File

@@ -117,7 +117,7 @@ uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *ev
ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy);
const ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_ANY, event->xy);
uiBut *but = ui_but_find_mouse_over(region, event);
uiBut *but = UI_but_find_mouse_over(region, event);
if (ELEM(nullptr, but, but->rnapoin.data, but->rnaprop)) {
return nullptr;

View File

@@ -9708,7 +9708,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
}
#endif
case MOUSEMOVE: {
uiBut *but_other = ui_but_find_mouse_over(region, event);
uiBut *but_other = UI_but_find_mouse_over(region, event);
bool exit = false;
/* always deactivate button for pie menus,
@@ -9870,7 +9870,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
}
}
bt = ui_but_find_mouse_over(region, event);
bt = UI_but_find_mouse_over(region, event);
if (bt && bt->active != data) {
if (but->type != ButType::Color) { /* exception */
@@ -9882,7 +9882,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
}
case RIGHTMOUSE: {
if (event->val == KM_PRESS) {
uiBut *bt = ui_but_find_mouse_over(region, event);
uiBut *bt = UI_but_find_mouse_over(region, event);
if (bt && bt->active == data) {
button_activate_state(C, bt, BUTTON_STATE_HIGHLIGHT);
}
@@ -9951,7 +9951,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
* it stays active while the mouse is over it.
* This avoids adding mouse-moves, see: #33466. */
if (ELEM(state_orig, BUTTON_STATE_INIT, BUTTON_STATE_HIGHLIGHT, BUTTON_STATE_WAIT_DRAG)) {
if (ui_but_find_mouse_over(region, event) == but) {
if (UI_but_find_mouse_over(region, event) == but) {
button_activate_init(C, region, but, BUTTON_ACTIVATE_OVER);
}
}
@@ -12127,7 +12127,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void * /*us
(ui_region_find_active_but(data->menu->region) == nullptr) &&
/* make sure mouse isn't inside another menu (see #43247) */
(ui_screen_region_find_mouse_over(screen, event) == nullptr) &&
(but_other = ui_but_find_mouse_over(region, event)) &&
(but_other = UI_but_find_mouse_over(region, event)) &&
ui_can_activate_other_menu(but, but_other, event) &&
/* Hover-opening menu's doesn't work well for buttons over one another
* along the same axis the menu is opening on (see #71719). */

View File

@@ -1549,7 +1549,6 @@ uiBut *ui_but_find_mouse_over_ex(const ARegion *region,
const uiButFindPollFn find_poll,
const void *find_custom_data)
ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_but_find_mouse_over(const ARegion *region, const wmEvent *event) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_but_find_rect_over(const ARegion *region, const rcti *rect_px) ATTR_WARN_UNUSED_RESULT;
uiBut *ui_list_find_mouse_over_ex(const ARegion *region, const int xy[2])

View File

@@ -368,7 +368,7 @@ uiBut *ui_but_find_mouse_over_ex(const ARegion *region,
return butover;
}
uiBut *ui_but_find_mouse_over(const ARegion *region, const wmEvent *event)
uiBut *UI_but_find_mouse_over(const ARegion *region, const wmEvent *event)
{
return ui_but_find_mouse_over_ex(
region, event->xy, event->modifier & KM_CTRL, false, nullptr, nullptr);

View File

@@ -231,6 +231,11 @@ static wmOperatorStatus node_group_enter_exit_invoke(bContext *C,
SpaceNode &snode = *CTX_wm_space_node(C);
ARegion &region = *CTX_wm_region(C);
/* Don't interfer when the mouse is interacting with some button. See #147282. */
if (ISMOUSE_BUTTON(event->type) && UI_but_find_mouse_over(&region, event)) {
return OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED;
}
float2 cursor;
UI_view2d_region_to_view(&region.v2d, event->mval[0], event->mval[1], &cursor.x, &cursor.y);
bNode *node = node_under_mouse_get(snode, cursor);