diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-16 10:32:12 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-16 10:32:12 +0300 |
commit | d272300da95648ccc5b383ab9debb19707aa48e3 (patch) | |
tree | 4f230992e1bf5decb1c097069f52e63310a83f69 | |
parent | 89101d51bc7fb3931de29248d57bffb2530d58d2 (diff) |
UI: bring back function to convert keyboard event to string, and
make the key event button work again.
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 15 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 315 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 5 |
5 files changed, 331 insertions, 17 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2562a5e6bb3..ed1e546ec0a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -44,6 +44,7 @@ #include "BLI_dynstr.h" #include "BKE_global.h" +#include "BKE_library.h" #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -1587,8 +1588,7 @@ void ui_check_but(uiBut *but) if (but->flag & UI_SELECT) { strcat(but->drawstr, "Press a key"); } else { - /* XXX 2.50 function not supported */ - /* strcat(but->drawstr, key_event_to_string((short) ui_get_but_val(but))); */ + strcat(but->drawstr, WM_key_event_string((short) ui_get_but_val(but))); } break; @@ -2073,8 +2073,8 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname) /* autocomplete callback for ID buttons */ static void autocomplete_id(bContext *C, char *str, void *arg_v) { - /* int blocktype= (intptr_t)arg_v; */ - ListBase *listb= NULL /* XXX 2.50 needs context, wich_libbase(G.main, blocktype) */; + int blocktype= (intptr_t)arg_v; + ListBase *listb= wich_libbase(G.main, blocktype); /* XXX */ if(listb==NULL) return; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 994fdc18d1a..a5a38c34447 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1449,17 +1449,14 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w if(event->type == MOUSEMOVE) return WM_UI_HANDLER_CONTINUE; - /* XXX 2.50 missing function */ -#if 0 if(event->val) { - if(!key_event_to_string(event)[0]) - data->cancel= 1; - else + if(WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); + else + data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } -#endif } return WM_UI_HANDLER_CONTINUE; @@ -2660,8 +2657,12 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) /* check if the mouse is in the region, and in case of a view2d also check * if it is inside the view2d itself, not over scrollbars for example */ - if(!BLI_in_rcti(&ar->winrct, x, y)) + if(!BLI_in_rcti(&ar->winrct, x, y)) { + for(block=ar->uiblocks.first; block; block=block->next) + block->auto_open= 0; + return NULL; + } if(ar->v2d.mask.xmin!=ar->v2d.mask.xmax) { mx= x; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a2544e3e6e5..2d60f82ea7c 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -61,7 +61,7 @@ void WM_cursor_restore (struct wmWindow *win); void WM_cursor_wait (struct wmWindow *win, int val); void WM_timecursor (struct wmWindow *win, int nr); - /* keymap and handlers */ + /* keymap */ wmKeymapItem *WM_keymap_set_item (ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, @@ -71,6 +71,9 @@ wmKeymapItem *WM_keymap_add_item (ListBase *lb, char *idname, short type, ListBase *WM_keymap_listbase (wmWindowManager *wm, const char *nameid, int spaceid, int regionid); +char *WM_key_event_string(short type); + + /* handlers */ struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap); /* boundbox, optional subwindow boundbox for offset */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 0e962408b55..4d99425b35b 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -167,3 +167,318 @@ ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, int spacei return &km->keymap; } +/* ***************** get string from key events **************** */ + +char *WM_key_event_string(short type) +{ + /* not returned: CAPSLOCKKEY, UNKNOWNKEY, COMMANDKEY, GRLESSKEY */ + + switch(type) { + case AKEY: + return "A"; + break; + case BKEY: + return "B"; + break; + case CKEY: + return "C"; + break; + case DKEY: + return "D"; + break; + case EKEY: + return "E"; + break; + case FKEY: + return "F"; + break; + case GKEY: + return "G"; + break; + case HKEY: + return "H"; + break; + case IKEY: + return "I"; + break; + case JKEY: + return "J"; + break; + case KKEY: + return "K"; + break; + case LKEY: + return "L"; + break; + case MKEY: + return "M"; + break; + case NKEY: + return "N"; + break; + case OKEY: + return "O"; + break; + case PKEY: + return "P"; + break; + case QKEY: + return "Q"; + break; + case RKEY: + return "R"; + break; + case SKEY: + return "S"; + break; + case TKEY: + return "T"; + break; + case UKEY: + return "U"; + break; + case VKEY: + return "V"; + break; + case WKEY: + return "W"; + break; + case XKEY: + return "X"; + break; + case YKEY: + return "Y"; + break; + case ZKEY: + return "Z"; + break; + + case ZEROKEY: + return "Zero"; + break; + case ONEKEY: + return "One"; + break; + case TWOKEY: + return "Two"; + break; + case THREEKEY: + return "Three"; + break; + case FOURKEY: + return "Four"; + break; + case FIVEKEY: + return "Five"; + break; + case SIXKEY: + return "Six"; + break; + case SEVENKEY: + return "Seven"; + break; + case EIGHTKEY: + return "Eight"; + break; + case NINEKEY: + return "Nine"; + break; + + case LEFTCTRLKEY: + return "Leftctrl"; + break; + case LEFTALTKEY: + return "Leftalt"; + break; + case RIGHTALTKEY: + return "Rightalt"; + break; + case RIGHTCTRLKEY: + return "Rightctrl"; + break; + case RIGHTSHIFTKEY: + return "Rightshift"; + break; + case LEFTSHIFTKEY: + return "Leftshift"; + break; + + case ESCKEY: + return "Esc"; + break; + case TABKEY: + return "Tab"; + break; + case RETKEY: + return "Ret"; + break; + case SPACEKEY: + return "Space"; + break; + case LINEFEEDKEY: + return "Linefeed"; + break; + case BACKSPACEKEY: + return "Backspace"; + break; + case DELKEY: + return "Del"; + break; + case SEMICOLONKEY: + return "Semicolon"; + break; + case PERIODKEY: + return "Period"; + break; + case COMMAKEY: + return "Comma"; + break; + case QUOTEKEY: + return "Quote"; + break; + case ACCENTGRAVEKEY: + return "Accentgrave"; + break; + case MINUSKEY: + return "Minus"; + break; + case SLASHKEY: + return "Slash"; + break; + case BACKSLASHKEY: + return "Backslash"; + break; + case EQUALKEY: + return "Equal"; + break; + case LEFTBRACKETKEY: + return "Leftbracket"; + break; + case RIGHTBRACKETKEY: + return "Rightbracket"; + break; + + case LEFTARROWKEY: + return "Leftarrow"; + break; + case DOWNARROWKEY: + return "Downarrow"; + break; + case RIGHTARROWKEY: + return "Rightarrow"; + break; + case UPARROWKEY: + return "Uparrow"; + break; + + case PAD2: + return "Pad2"; + break; + case PAD4: + return "Pad4"; + break; + case PAD6: + return "Pad6"; + break; + case PAD8: + return "Pad8"; + break; + case PAD1: + return "Pad1"; + break; + case PAD3: + return "Pad3"; + break; + case PAD5: + return "Pad5"; + break; + case PAD7: + return "Pad7"; + break; + case PAD9: + return "Pad9"; + break; + + case PADPERIOD: + return "Padperiod"; + break; + case PADSLASHKEY: + return "Padslash"; + break; + case PADASTERKEY: + return "Padaster"; + break; + + case PAD0: + return "Pad0"; + break; + case PADMINUS: + return "Padminus"; + break; + case PADENTER: + return "Padenter"; + break; + case PADPLUSKEY: + return "Padplus"; + break; + + case F1KEY: + return "F1"; + break; + case F2KEY: + return "F2"; + break; + case F3KEY: + return "F3"; + break; + case F4KEY: + return "F4"; + break; + case F5KEY: + return "F5"; + break; + case F6KEY: + return "F6"; + break; + case F7KEY: + return "F7"; + break; + case F8KEY: + return "F8"; + break; + case F9KEY: + return "F9"; + break; + case F10KEY: + return "F10"; + break; + case F11KEY: + return "F11"; + break; + case F12KEY: + return "F12"; + break; + + case PAUSEKEY: + return "Pause"; + break; + case INSERTKEY: + return "Insert"; + break; + case HOMEKEY: + return "Home"; + break; + case PAGEUPKEY: + return "Pageup"; + break; + case PAGEDOWNKEY: + return "Pagedown"; + break; + case ENDKEY: + return "End"; + break; + } + + return ""; +} + diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 87c9e3cb2db..6fc9aa86e12 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -188,11 +188,6 @@ #define COMMANDKEY 172 #define GRLESSKEY 173 -/* used as fake leftmouse events, special handled in interface.c */ -#define BUT_ACTIVATE 200 -#define BUT_NEXT 201 -#define BUT_PREV 202 - /* **************** BLENDER QUEUE EVENTS ********************* */ #define CHANGED 0x4000 |