static int dm_placeModuleUnderAIBar_expiry = 4000; // return true if we are first sbool dm_placeModuleUnderAIBar(O moduleOrID, fS query) { fO module = dm_getModule(moduleOrID); fS moduleID = dm_moduleID(moduleOrID); dm_showModule_noFocus(module); ret swing(func -> bool { JTextComponent aiBar = cast getCreatorOpt('tfTopInput); Rect mr = dm_getBounds(module); if (aiBar == null || mr == null) false; Rectangle r = getBounds(aiBar); // height / query / timestamp T3 p = optCast(T3, quickImport(dm_generalMap_get('modulesUnderAIBar_y))); bool first = !(p != null && eq(p.b, query) && sysNow() <= p.c+dm_placeModuleUnderAIBar_expiry /*&& p.a != mr.y2()*/); int y = first ? 0 : p.a; // place on top if there is space (doesn't work like this) //if (y >= mr.h) y = 0; if (first) dm_generalMap_put('modulesUnderAIBar_firstModule, moduleID); //print("dm_place: " + p + " / " + y); dm_setBounds(module, r.x, y, r.width, mr.h); int yOut = y+mr.h; if (!first && p != null) yOut = max(yOut, p.a); dm_generalMap_put('modulesUnderAIBar_y, t3(yOut, query, y == 0 ? sysNow() : p.c)); if (first) vmBus_send('placedModuleUnderAIBar, module); ret first; }); }