media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

template-rif-focushandler.vr

template-rif-focushandler.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  DEF FOCUSHANDLER Script {
      eventIn SFNode 
  requestFocus
      field   SFNode currentFocus NULL
      field   SFNode inputHandler USE INPUTHANDLER
      field   SFInt32 oldMask 0
      url "vrmlscript:
   
         function initialize()
          {
              // tell what events
              oldMask = Browser.eventMask;
              Browser.eventMask = 1<<5; // KeyDown Only...
              // add event observer
              Browser.addRoute(Browser,'event_changed',inputHandler,'onEvent');
   
         }
          function shutdown()
          {
              requestFocus(null,0);
              // remove event observer
              Browser.eventMask = oldMask;
              Browser.deleteRoute(Browser,'event_changed',inputHandler,'onEvent');
   
         }
          function requestFocus(value,time) {
              if(currentFocus != null) {
  //                Browser.print('Removing keyboard focus from thing...');
                  Browser.deleteRoute(inputHandler,'charCode',
   
                                     currentFocus,'characterInput');
                  currentFocus.setTransparency = 0.8;
              }
              currentFocus = null;
              if(value != null) {
  //                Browser.print('Adding keyboard focus for thing...');
                  currentFocus 
  = value;
                  Browser.addRoute(inputHandler,'charCode',
                                   currentFocus,'characterInput');
                  currentFocus.setTransparency 
  = 0;
              }
          }
      "
  }
  

[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.