!7 !include once #1020738 // Loadable Utils srecord Definition(S word, S definition) {} module DefinitionsByVoice > DynObjectTable { bool voiceMode; visualize { ret withRightAlignedButtons(super.visualize(), dm_fieldCheckBox('voiceMode)); } start { dm_useLocalMechListCopies(); dontPersist(); fieldsInOrder = true; dm_onTopInput(voidfunc(fS s) { reactTo(s) }); reactTo(dm_getTopInput()); } void _search(fS s) { bool wasEmpty = count() == 0; L l = map(func(S def) -> Definition { Definition(s, def) }, dm_getDefinitions(s)); if (empty(l)) ret; addAll(l); vmBus_send(wasEmpty ? 'firstResults : 'moreResults, this); if (voiceMode && wasEmpty) dm_say(first(l).definition); } // API void reactTo(fS s) enter { switch to q(); clear(); _search(s); new Matches m; for (S x : matchX_any_allRests(mL("Query Definition Patterns"), s)) _search(x); if (nempty(data)) dm_showModule_noFocus(); } }