2.5
authorTon Roosendaal <ton@blender.org>
Sun, 16 Aug 2009 17:42:09 +0000 (17:42 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 16 Aug 2009 17:42:09 +0000 (17:42 +0000)
Muscle flexing commit; put the "any key modifier" to work, also exposed
(ugly) in keymap editor. Notes for it works:

- You can use any keyboard key to become modifier now (not mouse buttons)
- But, if this key was assigned to be a regular hotkey, that still gets
  triggered, obviously.
- So: only use unused keys for this, like "~" or other special ones?

For test fun: L+K now does animplay.

source/blender/editors/screen/screen_ops.c
source/blender/editors/space_outliner/outliner.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_window.c

index 9453c7ffe098916378dda89adde9e57ffdd1af49..9fcee99aa5622c6df1f597b70cabca2a18f8fe74 100644 (file)
@@ -3363,6 +3363,7 @@ void ED_keymap_screen(wmWindowManager *wm)
        
        /* play (forward and backwards) */
        WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY);
        RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1);
 
        keymap_modal_set(wm);
index 33119317a6da246d837e834fa7dcba6eeea95e90..e676b429687e5781e6a5c92d03ca62623f057607 100644 (file)
@@ -5162,13 +5162,13 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                                }
                                
                                /* modifiers */
-                               uiBlockBeginAlign(block);
                                uiDefButS(block, OPTION, 0, "Shift",    xstart, (int)te->ys+1, butw3+5, OL_H-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5;
                                uiDefButS(block, OPTION, 0, "Ctrl",     xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
                                uiDefButS(block, OPTION, 0, "Alt",      xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
                                uiDefButS(block, OPTION, 0, "Cmd",      xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3;
                                xstart+= 5;
-                               uiBlockEndAlign(block);
+                               uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, OL_H-1, &kmi->keymodifier, "Key Modifier code");
+                               xstart+= butw3+5;
                                
                                /* rna property */
                                if(kmi->ptr && kmi->ptr->data)
index 05be825b3bd806172f30d5cd2eff7b9bf48206f3..737028843d39f43ab66d4bc111a837bc24902549 100644 (file)
@@ -691,8 +691,15 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi)
                if(winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0;
        if(kmi->oskey!=KM_ANY)
                if(winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0;
+       
        if(kmi->keymodifier)
                if(winevent->keymodifier!=kmi->keymodifier) return 0;
+               
+       /* key modifiers always check when event has it */
+       /* otherwise regular keypresses with keymodifier still work */
+       if(winevent->keymodifier)
+               if(ISKEYBOARD(winevent->type)) 
+                       if(winevent->keymodifier!=kmi->keymodifier) return 0;
        
        return 1;
 }
@@ -1509,11 +1516,6 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata)
                        else
                                event.type= MIDDLEMOUSE;
                        
-                       if(event.val)
-                               event.keymodifier= evt->keymodifier= event.type;
-                       else
-                               event.keymodifier= evt->keymodifier= 0;
-                       
                        update_tablet_data(win, &event);
                        wm_event_add(win, &event);
                        
@@ -1552,6 +1554,12 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata)
                                if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->shift))
                                   event.oskey= evt->oskey = 3;         // define?
                        }
+                       else {
+                               if(event.val==KM_PRESS && event.keymodifier==0)
+                                       evt->keymodifier= event.type; /* only set in eventstate, for next event */
+                               else if(event.val==KM_RELEASE && event.keymodifier==event.type)
+                                       event.keymodifier= evt->keymodifier= 0;
+                       }
                        
                        /* if test_break set, it catches this. XXX Keep global for now? */
                        if(event.type==ESCKEY)
index 3006944533aef4bffff2f54a2c226728708ff3c3..a6fbb0515bc4ff6233f8ca94a8a37a64ea1dc14d 100644 (file)
@@ -588,6 +588,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
                                        kdata.key= GHOST_kKeyCommand;
                                        wm_event_add_ghostevent(win, GHOST_kEventKeyUp, &kdata);
                                }
+                               /* keymodifier zero, it hangs on hotkeys that open windows otherwise */
+                               win->eventstate->keymodifier= 0;
                                
                                /* entering window, update mouse pos. but no event */
                                GHOST_GetCursorPosition(g_system, &wx, &wy);