abstract sclass DynDialogWithUser > DynModule { L<DialogItem> dialog = synchroList(); S input; transient JTextArea taDialog; transient JTextField tfInput; transient L onUserInput; sclass DialogItem { S author, line; long timestamp = now(); toString { ret "[" + localTimeWithSeconds(timestamp) + "] " + author + ": " + line; } } visualize { tfInput = dm_fieldTextField('input); onEnter(tfInput, rThread sendInput); ret centerAndSouthWithMargins( jSection("Dialog", taDialog = setDisabledTextColor(Color.black, makeUneditable(jLiveValueWordWrapTypeWriterTextArea_autoScroll( dm_calculatedLiveValue(S, func -> S { dialogToString() }))))), withLabel("Your input:", tfInput)); } void sendInput { S input = this.input; addLine('User, input); selectAll(tfInput); pcallFAll(onUserInput, input); } void onUserInput(VF1<S> r) { onUserInput = createOrAddToSyncList(onUserInput, r); } // API S dialogToString() { ret lines_rtrim(allToString(cloneList(dialog))); } void addLine(S author, S line) { dialog.add(nu(DialogItem.class, +author, +line)); change(); } }
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: | 288 / 831 |
Version history: | 15 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |