1 | abstract sclass DynDialogWithUser > DynModule {
|
2 | L<DialogItem> dialog = synchroList(); |
3 | S input; |
4 | |
5 | transient JTextArea taDialog; |
6 | transient JTextField tfInput; |
7 | transient L onUserInput; |
8 | |
9 | sclass DialogItem {
|
10 | S author, line; |
11 | long timestamp = now(); |
12 | |
13 | toString { ret "[" + localTimeWithSeconds(timestamp) + "] " + author + ": " + line; }
|
14 | } |
15 | |
16 | visualize {
|
17 | tfInput = dm_fieldTextField('input);
|
18 | onEnter(tfInput, rThread sendInput); |
19 | ret centerAndSouthWithMargins( |
20 | jSection("Dialog", taDialog = setDisabledTextColor(Color.black, makeUneditable(jLiveValueWordWrapTypeWriterTextArea_autoScroll(
|
21 | dm_calculatedLiveValue(S, func -> S { dialogToString() }))))),
|
22 | withLabel("Your input:", tfInput));
|
23 | } |
24 | |
25 | void sendInput {
|
26 | S input = this.input; |
27 | addLine('User, input);
|
28 | selectAll(tfInput); |
29 | pcallFAll(onUserInput, input); |
30 | } |
31 | |
32 | void onUserInput(VF1<S> r) {
|
33 | onUserInput = createOrAddToSyncList(onUserInput, r); |
34 | } |
35 | |
36 | // API |
37 | |
38 | S dialogToString() {
|
39 | ret lines_rtrim(allToString(cloneList(dialog))); |
40 | } |
41 | |
42 | void addLine(S author, S line) {
|
43 | dialog.add(nu(DialogItem.class, +author, +line)); |
44 | change(); |
45 | } |
46 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1020937 |
| Snippet name: | DynDialogWithUser |
| Eternal ID of this version: | #1020937/16 |
| Text MD5: | 07c6e70424bc7766556caf899bf81060 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-01-12 15:33:09 |
| Source code size: | 1228 bytes / 46 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 495 / 1045 |
| Version history: | 15 change(s) |
| Referenced in: | [show references] |