static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op) { static char search[256] = ""; wmEvent event; wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; wmOperator *op = (wmOperator *)arg_op; block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); uiButSetSearchFunc(but, node_find_cb, op->type, node_find_call_cb, NULL); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ uiEndBlock(C, block); // uiButActiveOnly(C, ar, block, but); XXX using this here makes Blender hang - investigate wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; event.customdatafree = FALSE; wm_event_add(win, &event); return block; }
/* ID Search browse menu, open */ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) { static char search[OP_MAX_TYPENAME]; wmEvent event; wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; /* clear initial search string, then all items show */ search[0] = 0; block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); uiBoundsBlock(block, 6); uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); event = *(win->eventstate); /* XXX huh huh? make api call */ event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; event.customdatafree = FALSE; wm_event_add(win, &event); return block; }