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).

!7

cmodule ConfirmAction > DynModule {
  S text;
  transient Runnable action;
  
  Pt minimumSize() { ret pt(400, 200); }
  
  start {
    dm_onUserUtterance(s -> { if "yes" yes(); if "no" reset(); });
  }
  
  visual withCenteredButtons(
    withMargin(fontSizePlus(10, dm_centeredLabel text())),
    "Yes", rThread yes, "No", rThread reset);
    
  void reset enter {
    setFields(text := "", action := null);
    dm_disableAllButtons();
    dm_popInModule();
    dm_hideModule();
  }
    
  void yes enter {
    if (action == null) ret;
    if (!dm_moduleIsPoppedOut()) ret with reset();
    print("Running action: " + text);
    Runnable r = action;
    reset();
    callF(r);
  }
  
  // API
  
  void showAction(S text, Runnable action) {
    setFields(+text, +action);
    dm_enableAllButtons();
    dm_popOutModule_alwaysOnTop();
  }
}

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: 316 / 4460
Version history: 9 change(s)
Referenced in: #1026778 - dm_confirmAction