Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1026774 // Confirm action

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (5942L/29K).

1  
!7
2  
3  
cmodule ConfirmAction > DynModule {
4  
  S text;
5  
  transient Runnable action;
6  
  
7  
  Pt minimumSize() { ret pt(400, 200); }
8  
  
9  
  start {
10  
    dm_onUserUtterance(s -> { if "yes" yes(); if "no" reset(); });
11  
  }
12  
  
13  
  visual withCenteredButtons(
14  
    withMargin(fontSizePlus(10, dm_centeredLabel text())),
15  
    "Yes", rThread yes, "No", rThread reset);
16  
    
17  
  void reset enter {
18  
    setFields(text := "", action := null);
19  
    dm_disableAllButtons();
20  
    dm_popInModule();
21  
    dm_hideModule();
22  
  }
23  
    
24  
  void yes enter {
25  
    if (action == null) ret;
26  
    if (!dm_moduleIsPoppedOut()) ret with reset();
27  
    print("Running action: " + text);
28  
    Runnable r = action;
29  
    reset();
30  
    callF(r);
31  
  }
32  
  
33  
  // API
34  
  
35  
  void showAction(S text, Runnable action) {
36  
    setFields(+text, +action);
37  
    dm_enableAllButtons();
38  
    dm_popOutModule_alwaysOnTop();
39  
  }
40  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026774
Snippet name: Confirm action
Eternal ID of this version: #1026774/10
Text MD5: ed52edee81aa14fdb92772bf4f061982
Transpilation MD5: f474508773057c02114f23baf8062baa
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-02-17 17:41:27
Source code size: 884 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 315 / 4460
Version history: 9 change(s)
Referenced in: [show references]