Bugfix, own collection
authorTon Roosendaal <ton@blender.org>
Wed, 15 Dec 2010 18:09:25 +0000 (18:09 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 15 Dec 2010 18:09:25 +0000 (18:09 +0000)
Using RMB on menus to change hotkeys was broken.
- the input button was on a weird place outside menu, assign
  would close pulldown, so you had to reopen to check
- ESC didn't close the button, but assigned ESC as hotkey.
  This key is a protected key, and always should be escaping.
- Worst bug: if you used this on a 'user keymap' it removed
  all entries from the map...

source/blender/editors/interface/interface_handlers.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/wm_event_types.h

index e15696d7e80f9c36775317f37f5e1a3e63f919d1..77782e56f2319a4d9ea6eead21c49f3da0a31194 100644 (file)
@@ -2081,6 +2081,12 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                return WM_UI_HANDLER_BREAK;
                        }
+                       else if(event->type == ESCKEY) {
+                               data->cancel= 1;
+                               data->escapecancel= 1;
+                               button_activate_state(C, but, BUTTON_STATE_EXIT);
+                       }
+                       
                }
        }
        
@@ -4011,14 +4017,14 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
        
        block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
        uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
-       uiBlockSetFlag(block, UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT);
+       uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
        uiBlockSetDirection(block, UI_CENTER);
        
        layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
        
        uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT|UI_ITEM_R_IMMEDIATE, "", 0);
        
-       uiPopupBoundsBlock(block, 6, 100, 10);
+       uiPopupBoundsBlock(block, 6, -50, 26);
        uiEndBlock(C, block);
        
        return block;
@@ -4056,7 +4062,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
 
        uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT|UI_ITEM_R_IMMEDIATE, "", 0);
        
-       uiPopupBoundsBlock(block, 6, 100, 10);
+       uiPopupBoundsBlock(block, 6, -50, 26);
        uiEndBlock(C, block);
        
        return block;
index df635c0ccb2e1c037480a203f97c3093b71d598a..a3f662cbbf33b1556fa87c6ede7abeb83925fb8c 100644 (file)
@@ -652,6 +652,10 @@ wmKeyMap *WM_keymap_copy_to_user(wmKeyMap *keymap)
 
        usermap= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
 
+       /* XXX this function is only used by RMB setting hotkeys, and it clears maps on 2nd try this way */
+       if(keymap==usermap)
+               return keymap;
+       
        if(!usermap) {
                /* not saved yet, duplicate existing */
                usermap= MEM_dupallocN(keymap);
index 822b36392ce7820564fe60a51f4725fc1bb553ed..5d7eb625f7877e43e41bf4aee0881f1b36a95e79 100644 (file)
 #define ISTWEAK(event) (event >= EVT_TWEAK_L && event <= EVT_GESTURE)
 
 /* test whether event type is acceptable as hotkey, excluding modifiers */
-#define ISHOTKEY(event)        ((ISKEYBOARD(event) || ISMOUSE(event)) && !(event>=LEFTCTRLKEY && event<=LEFTSHIFTKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY))
+#define ISHOTKEY(event)        ((ISKEYBOARD(event) || ISMOUSE(event)) && event!=ESCKEY && !(event>=LEFTCTRLKEY && event<=LEFTSHIFTKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY))
 
 /* **************** BLENDER GESTURE EVENTS (0x5000) **************** */