Uses 911K of libraries. Click here for Pure Java version (3022L/15K).
1 | !7 |
2 | |
3 | // function: func(S) -> bool (true = handled) |
4 | // guiComponent may be null |
5 | srecord VoiceTarget(S moduleID, JComponent guiComponent, O function) {}
|
6 | |
7 | cmodule VoiceTargets > DynObjectTable<VoiceTarget> {
|
8 | start {
|
9 | dontPersist(); |
10 | dm_onTopInput_q(voidfunc(S s) {
|
11 | for (VoiceTarget vt : getVoiceTargets()) {
|
12 | if (!dm_moduleExists(vt.moduleID)) continue with remove(vt); |
13 | temp dm_enter(vt.moduleID); |
14 | if (isTrue(callF(vt.function, s))) ret; |
15 | } |
16 | }); |
17 | } |
18 | |
19 | // hold targets during reload |
20 | |
21 | O _getReloadData() { ret data; }
|
22 | void _setReloadData(L data) { main addAll(this.data, map(data, func(O o) -> VoiceTarget { shallowCloneToClass(VoiceTarget, o) })); }
|
23 | |
24 | // API |
25 | |
26 | void addVoiceTarget(S moduleID, JComponent guiComponent, O function) enter {
|
27 | assertNotNull(+guiComponent); |
28 | assertNempty(+moduleID); |
29 | final VoiceTarget vt = new(moduleID, guiComponent, function); |
30 | bindToComponent(guiComponent, |
31 | r { add(vt) },
|
32 | r { remove(vt) });
|
33 | } |
34 | |
35 | L<VoiceTarget> getVoiceTargets() enter {
|
36 | ret cloneList(data); |
37 | } |
38 | } |
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1020309 |
| Snippet name: | Voice Targets - where does voice input go? |
| Eternal ID of this version: | #1020309/14 |
| Text MD5: | 7f6c4989cd65ff33a2c35b7d2625437d |
| Transpilation MD5: | d4f6b6f501aaf926494adad5fa694053 |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-23 13:25:37 |
| Source code size: | 1119 bytes / 38 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 550 / 1123 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |