patch [#23675] fix #22787 with workaround
authorCampbell Barton <ideasman42@gmail.com>
Wed, 22 Sep 2010 17:13:23 +0000 (17:13 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 22 Sep 2010 17:13:23 +0000 (17:13 +0000)
from Shane Ambler (sambler)

source/blender/editors/interface/interface_handlers.c

index fea152bb4a747f5570a50e149a3c59a6a4f09315..e411872964a7eb74b3bf01b44f2e6362e1e7216b 100644 (file)
@@ -5404,20 +5404,44 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu,
                                                if(event->val==KM_PRESS) {
                                                        but= ui_but_find_activated(ar);
                                                        if(but) {
-                                                               if(ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) 
-                                                                       but= ui_but_next(but);
-                                                               else
-                                                                       but= ui_but_prev(but);
+                                                               /* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */
+                                                               /* UI_TOP and UI_DOWN are inconsistant - should be UI_UP and UI_DOWN or UI_TOP and UI_BOTTOM */
+                                                               if(     ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) ||
+                                                                       ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP))
+                                                               ) {
+                                                                       /* the following is just a hack - uiBut->type set to BUT and BUTM have there menus built 
+                                                                        * opposite ways - this should be changed so that all popup-menus use the same uiBlock->direction */
+                                                                       if(but->type & BUT)
+                                                                               but= ui_but_next(but);
+                                                                       else
+                                                                               but= ui_but_prev(but);
+                                                               }
+                                                               else {
+                                                                       if(but->type & BUT)
+                                                                               but= ui_but_prev(but);
+                                                                       else
+                                                                               but= ui_but_next(but);
+                                                               }
 
                                                                if(but)
                                                                        ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
                                                        }
 
                                                        if(!but) {
-                                                               if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE))
-                                                                       bt= ui_but_last(block);
-                                                               else
-                                                                       bt= ui_but_first(block);
+                                                               if(     ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) ||
+                                                                       ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP))
+                                                               ) {
+                                                                       if(ui_but_first(block)->type & BUT)
+                                                                               bt= ui_but_last(block);
+                                                                       else
+                                                                               bt= ui_but_first(block);
+                                                               }
+                                                               else {
+                                                                       if(ui_but_first(block)->type & BUT)
+                                                                               bt= ui_but_first(block);
+                                                                       else
+                                                                               bt= ui_but_last(block);
+                                                          }
 
                                                                if(bt)
                                                                        ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE);