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

18
LINES

< > BotCompany Repo | #1025206 - lvFlexibleRateTimerFreq (two-way string live value for text fields)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3708L/24K).

static SimpleLiveValue<S> lvFlexibleRateTimerFreq(FlexibleRateTimer timer, O... _) {
  SimpleLiveValue<S> lvRate = stringLiveValue();
  optPar int delayOnInput = 1000; // how long to wait after someone typed a new frequency value (ms)
  
  embedded S formattedFrequency() {
    ret formatDouble(timer.getFrequency(), 3);
  }

  lvRate.onChange(rLater(delayOnInput, r {
    S s = trim(lvRate!);
    if (eq(s, formattedFrequency())) ret;
    Double hz = parseDoubleOpt(s), ret if null;
    timer.setFrequencyImmediately(hz);
  }));
  
  timer.onFrequencyChangedAndNow(r{ lvRate.set(formattedFrequency()) });
  ret lvRate;
}

Author comment

Began life as a copy of #1025194

download  show line numbers  debug dex   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz

No comments. add comment

Snippet ID: #1025206
Snippet name: lvFlexibleRateTimerFreq (two-way string live value for text fields)
Eternal ID of this version: #1025206/4
Text MD5: 60af49842bd794853de7bb09f12ad8c5
Transpilation MD5: 8e1fcb611e438922a91fc6da61573cfb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-13 13:48:37
Source code size: 638 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 35 / 63
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1025206 & http://1025206.tinybrain.de