diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-24 17:51:31 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-24 17:51:31 +0400 |
commit | c1c3d66079adb2e0ea7b7eb9bdb2997f37623591 (patch) | |
tree | 7e5c443db618d598a10306a9efc2d9684ef6c8d3 /source/blender/editors/interface | |
parent | 51014d8e4f45c132433f1319ddfa67419455c670 (diff) |
Fix #29306: Alt+N, Enter In Image View Does closes the dialog without executing.
If enter is pressed outside of any button in menu, generate two menu return values:
- UI_RETURN_CANCEL so button wouldn't be executed
- UI_RETURN_POPUP_OK so callback associated with popup block would be executed
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 18 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 1ba6acf367a..a0b0d34ab44 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5861,14 +5861,14 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut * menu= data->menu; /* copy over return values from the closing menu */ - if(menu->menuretval == UI_RETURN_OK || menu->menuretval == UI_RETURN_UPDATE) { + if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) { if(but->type == COL) copy_v3_v3(data->vec, menu->retvec); else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) data->value= menu->retvalue; } - if(menu->menuretval == UI_RETURN_UPDATE) { + if(menu->menuretval & UI_RETURN_UPDATE) { if(data->interactive) ui_apply_button(C, but->block, but, data, 1); else ui_check_but(but); @@ -5876,13 +5876,13 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut * } /* now change button state or exit, which will close the submenu */ - if(ELEM(menu->menuretval, UI_RETURN_OK, UI_RETURN_CANCEL)) { + if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) { if(menu->menuretval != UI_RETURN_OK) data->cancel= 1; button_activate_exit(C, data, but, 1, 0); } - else if(menu->menuretval == UI_RETURN_OUT) { + else if(menu->menuretval & UI_RETURN_OUT) { if(event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) { button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); } @@ -6330,7 +6330,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* enter will always close this block, we let the event * get handled by the button if it is activated, otherwise we cancel */ if(!ui_but_find_activated(ar)) - menu->menuretval= UI_RETURN_CANCEL; + menu->menuretval= UI_RETURN_CANCEL | UI_RETURN_POPUP_OK; } else { ui_mouse_motion_towards_check(block, menu, mx, my); @@ -6370,7 +6370,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle * buttons inside this region. disabled inside check .. not sure * anymore why it was there? but it meant enter didn't work * for example when mouse was not over submenu */ - if((/*inside &&*/ (!menu->menuretval || menu->menuretval == UI_RETURN_UPDATE) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { + if((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { but= ui_but_find_activated(ar); if(but) { @@ -6419,14 +6419,14 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo if(submenu->menuretval) { /* first decide if we want to close our own menu cascading, if * so pass on the sub menu return value to our own menu handle */ - if(ELEM(submenu->menuretval, UI_RETURN_OK, UI_RETURN_CANCEL)) { + if((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) { if(!(block->flag & UI_BLOCK_KEEP_OPEN)) { menu->menuretval= submenu->menuretval; menu->butretval= data->retval; } } - update= (submenu->menuretval == UI_RETURN_UPDATE); + update= (submenu->menuretval & UI_RETURN_UPDATE); /* now let activated button in this menu exit, which * will actually close the submenu too */ @@ -6599,7 +6599,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) ui_popup_block_free(C, menu); UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu); - if(temp.menuretval == UI_RETURN_OK) { + if((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) { if(temp.popup_func) temp.popup_func(C, temp.popup_arg, temp.retvalue); if(temp.optype) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index d117a7f4e6e..58c3c0130b8 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2603,7 +2603,7 @@ void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg) uiPupBlockO(C, func, arg, NULL, 0); } -void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_func, void *arg) +void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg) { wmWindow *window= CTX_wm_window(C); uiPopupBlockHandle *handle; @@ -2613,7 +2613,7 @@ void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockCancelFunc cancel_ handle->retvalue= 1; handle->popup_arg= arg; - // handle->popup_func= operator_cb; + handle->popup_func= popup_func; handle->cancel_func= cancel_func; // handle->opcontext= opcontext; |