コード例 #1
0
static wmKeyMapItem *wm_keymap_item_find_handlers(
        const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext),
        IDProperty *properties, int is_strict, int hotkey, wmKeyMap **keymap_r)
{
	wmWindowManager *wm = CTX_wm_manager(C);
	wmEventHandler *handler;
	wmKeyMap *keymap;
	wmKeyMapItem *kmi;

	/* find keymap item in handlers */
	for (handler = handlers->first; handler; handler = handler->next) {
		keymap = WM_keymap_active(wm, handler->keymap);

		if (keymap && (!keymap->poll || keymap->poll((bContext *)C))) {
			for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
				
				if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
					if (hotkey)
						if (!ISHOTKEY(kmi->type))
							continue;

					if (properties) {

						/* example of debugging keymaps */
#if 0
						if (kmi->ptr) {
							if (strcmp("MESH_OT_rip_move", opname) == 0) {
								printf("OPERATOR\n");
								IDP_spit(properties);
								printf("KEYMAP\n");
								IDP_spit(kmi->ptr->data);
							}
						}
#endif

						if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
							if (keymap_r) *keymap_r = keymap;
							return kmi;
						}
					}
					else {
						if (keymap_r) *keymap_r = keymap;
						return kmi;
					}
				}
			}
		}
	}
	
	/* ensure un-initialized keymap is never used */
	if (keymap_r) *keymap_r = NULL;
	return NULL;
}
コード例 #2
0
static wmKeyMapItem *wm_keymap_item_find_handlers(
    const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext),
    IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
{
	wmWindowManager *wm = CTX_wm_manager(C);
	wmEventHandler *handler;
	wmKeyMap *keymap;
	wmKeyMapItem *kmi;

	/* find keymap item in handlers */
	for (handler = handlers->first; handler; handler = handler->next) {
		keymap = WM_keymap_active(wm, handler->keymap);

		if (keymap && (!keymap->poll || keymap->poll((bContext *)C))) {
			for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
				
				if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
					if (hotkey)
						if (!ISHOTKEY(kmi->type))
							continue;
					
					if (compare_props) {
						if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
							if (keymap_r) *keymap_r = keymap;
							return kmi;
						}
					}
					else {
						if (keymap_r) *keymap_r = keymap;
						return kmi;
					}
				}
			}
		}
	}
	
	/* ensure un-initialized keymap is never used */
	if (keymap_r) *keymap_r = NULL;
	return NULL;
}
コード例 #3
0
ファイル: rna_wm_api.c プロジェクト: dfelinto/blender
static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
{
  wmWindowManager *wm = CTX_wm_manager(C);
  return WM_keymap_active(wm, km);
}