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

13
LINES

< > BotCompany Repo | #1018358 // bindTextComponentToIntLiveValue (both ways)

JavaX fragment (include)

static <A extends JTextComponent> A bindTextComponentToIntLiveValue(final A tc, final SimpleLiveValue<Int> lv) {
  final Var<Bool> dontRecurse = new(false);
  bindLiveValueListenerToComponent(tc, lv,
    r { if (!dontRecurse!) setTextKeepCaret(tc, strOrNull(lv!)) });
  onChange(tc, r {
    S s = gtt(tc);
    if (isInteger(s) || empty(s)) {
      temp tempSetVar(dontRecurse, true);
      lv.set(parseIntOpt(s));
    }
  });
  ret tc;
}

Author comment

Began life as a copy of #1016667

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018358
Snippet name: bindTextComponentToIntLiveValue (both ways)
Eternal ID of this version: #1018358/4
Text MD5: c31ed5caab76e43151647a52aba6df63
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-03 21:55:30
Source code size: 449 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 286 / 331
Version history: 3 change(s)
Referenced in: [show references]