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

37
LINES

< > BotCompany Repo | #1007440 - conceptLanguageToolTips

JavaX fragment (include)

sbool conceptLanguageToolTips_enabled;

svoid conceptLanguageToolTips() swing {
  if (conceptLanguageToolTips_enabled) ret;
  conceptLanguageToolTips_enabled = true;
  
  thread "conceptLanguageToolTips" {
    bool firstTime = true; // hack fix for tool tip not appearing the first time
    S initialMsg = "Move mouse over a concept word to reveal its meaning!";
    
    //repeat with ms sleep 500 {
    // Don't respond to "pause" button
    while (licensed_noPing()) {
      pcall {
        Component c = (Component) componentAtMouse_gen();
        if (c instanceof JComponent) {
          S word = wordAtMouse(), msg = firstTime ? initialMsg : "";
          
          if (possibleGlobalID(word)) {
            Lisp l = getLispTruth(word);
            S name = null;
            if (l != null)
              name = lispToEnglish_prettier(l);
            if (name == null)
              name = conceptToNameOpt(word); // This reloads AI concepts
            if (name != null) {
              msg = word + ": " + name;
              firstTime = false;
            }
          }
          setToolTipText((JComponent) c, msg);
        }
      }
      Thread.sleep(500);
    }
  }
}

Author comment

Began life as a copy of #1007437

download  show line numbers  debug dex   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1007440
Snippet name: conceptLanguageToolTips
Eternal ID of this version: #1007440/12
Text MD5: 7d61117d2444ce6027ec8452aba950a4
Author: stefan
Category: javax / gui / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-30 00:39:54
Source code size: 1217 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 275 / 263
Version history: 11 change(s)
Referenced in: [show references]

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