function NavigatableLabelBox (handleINSKey)
{
    /**
     * set focus to the edit box
     */
    this.setFocus = function() { 
	if( this.isEnabled() ) 
	    this.getTextBox().focus(); 
    }

    /**
     * (protected) called when escape is pressed
     * @private
     */
    this.onEscape = function() { }

    /**
     * (protected) called when key sequence for "home" is pressed
     * @private
     */
    this.onHome = function() { }

    /**
     * (protected) called when key sequence for "end" is pressed
     * @private
     */
    this.onEnd = function() { }

    /**
     * (protected) called when key sequence for "next" is pressed
     * @private
     */
    this.onNext = function() { }

    /**
     * (protected) called when key sequence for "prev" is pressed
     * @private
     */
    this.onPrev = function() { }

    /**
     * (protected) called when key sequence for up-arrow is pressed
     * @private
     */
    this.onUp = function() {}

    /**
     * (protected) called when key sequence for down-arrow is pressed
     * @private
     */
    this.onDown = function() {}

    /**
     * (protected) called when key sequence for INS key is pressed and
     * INS key should be handled
     * @private
     */
    this.onINS = function() {}

    /**
     * (protected) called when key sequence for Delete key is pressed
     * @private
     */
    this.onDelete = function() {return false;}

    /**
     * (protected) called when key sequence for "beginning of next line" is pressed
     * @private
     */
    this.onNextLine = function() {
    }

    /**
     * (protected) called when contents have changed
     * @private
     */
    this.onChange = function() { }

    /**
     * (protected) called when text box gets focus
     */
    this.onFocus = function() {
    }

    /**
     * (protected) called when text box looses focus
     */
    this.onBlur = function() {
    }

    /**
     * (protected) called when a non-navigational key is pressed
     * @param  cc	the character
     * @return true if key is handled and default processing should be foregone
     */
    this.onChar = function(cc) {
	    return false;
    }


    /**
     * did we handle last key pressed in keydown  - we do so only for
     * navigational keys
     * @type boolean
     * @private
     */
    this.fKeyHandled = false;
    this.fLastContents = null;

    /**
     * called when a key is pressed in the edit box
     * @private
     */
    this.keydown = function(event)
    {
	var cc = Utils.getCharFromEvent(event);
	var handled = true;
	if( cc == 9 || cc == 13 || (!this.fSpacesAllowed && cc == 32) ) {
	    if( cc != 13 ) {
		if(cc == 8 || event.shiftKey == 1 )
		    this.onPrev();
		else
		    this.onNext();
	    }
	    else
		this.onNextLine();
	}
	else if( cc == 27 ) // escape key
	    this.onEscape();
	else if( cc == 35 ) // end key 
	    this.onEnd();
	else if( cc == 36 ) // home key 
	    this.onHome();
	else if( cc == 37 ) // left key
	    this.onPrev();
	else if( cc == 38 ) // up key 
	    this.onUp();
	else if( cc == 39 ) // right key 
	    this.onNext();
	else if( cc == 40 ) // down key 
	    this.onDown();
	else if( cc == 45  && this.fHandleINSKey )
	    this.onINS();
	else if( cc == 46 )  {
	    handled = this.onDelete();
	}
	else
	    handled = this.onChar(cc);

	this.fKeyHandled = handled;
	if( handled ) {
	    // TODO: IE only, others require stopDefault, stopPropagation
	    event.returnValue = false;
	    if( event.stop )
		event.stop();
	    if( event.preventDefault )
		event.preventDefault();
	    if( event.stopPropagation )
		event.stopPropagation();
	    return false;
	}
	this.fLastContents = this.getTextBox().value;

	// others are processed as default
	return true;
    }

    /**
     * key down handler for IE
     * @private
     */
    function IE_textKeyDown() {
	this.fLabelBox.keydown(event);
    }
    this.IE_textKeyDown = IE_textKeyDown;


    /**
     * called when key is released
     * @private
     */
    this.keyup = function(event)
    {
	var cc = Utils.getCharFromEvent(event);
	//if( (cc == 32 && this.fSpacesAllowed) || (cc > 32 && cc <= 126 ))
	if( !this.fKeyHandled ) {
	    var v = this.getTextBox().value;
	    if( v != this.fLastContents )
		this.onChange();
	}
    }


    /**
     * key released handler for IE
     */
    function IE_textKeyUp() {
	this.fLabelBox.keyup(event);
    }
    this.IE_textKeyUp = IE_textKeyUp;

    /**
     * focus handler for IE
     */
    function IE_textFocus() {
	this.fLabelBox.onFocus();
    }
    this.IE_textFocus = IE_textFocus;

    /**
     * blur handler for IE
     */
    function IE_textBlur() {
	this.fLabelBox.onBlur();
    }
    this.IE_textBlur = IE_textBlur;

    /**
     *
     * (protected) to be called by derived class to initialize the control
     * @private
     * @param {boolean}  spacesAllowed 	are spaces allowed in label box (otherwise
     *					they act as navigational keys like tabs)
     */
    this.initLabelBox = function(isSpacesAllowed) {
	this.fSpacesAllowed = isSpacesAllowed;
	this.getTextBox().fLabelBox = this;
	// on IE. doing setAttribute doesnt work like we want
	if( Utils.isIE()) {
	    this.getTextBox().onkeydown = IE_textKeyDown;
	    this.getTextBox().onkeyup   = IE_textKeyUp;
	    this.getTextBox().onfocus   = IE_textFocus;
	    this.getTextBox().onblur    = IE_textBlur;
	}
	else {
	    this.getTextBox().setAttribute('onkeydown','this.fLabelBox.keydown(event);');
	    this.getTextBox().setAttribute('onkeyup','this.fLabelBox.keyup(event);');
	    this.getTextBox().setAttribute('onfocus','this.fLabelBox.onFocus();');
	    this.getTextBox().setAttribute('onblur', 'this.fLabelBox.onBlur();');
	}
    }


    /**
     * are spaces allowed in label box (otherwise they act as navigational keys like tabs)
     * @type boolean
     * @private
     */
    this.fSpacesAllowed = true;

    /**
     * should we handle INS key?
     */
    if( !handleINSKey ) handleINSKey = false;
    this.fHandleINSKey = handleINSKey;
}
/**
 * NavigatableLabelBox
 * represents a label edit box which supports navigational keys
 * <p>
 * It is sort of abstract in the sense and expects derived classes to implement
 * real logic in onChange, onNext, onPrev etc. The derived class <b>must</b> call
 * {@link LabelBox#initLabelBox} 
 * @constructoe
 * @param {boolean}	handleINSKey   		(optional) true if INS key 
 *						should be handled (and 
 *						{@link NavigatableLabelBox#onInsert}
 *						is called). Default if false;
 */
NavigatableLabelBox
represents a label edit box which supports navigational keys

It is sort of abstract in the sense and expects derived classes to implement
real logic in onChange, onNext, onPrev etc. The derived class must call
LabelBox#initLabelBox
@constructoe
@param {boolean}     handleINSKey            (optional) true if INS key
should be handled (and
NavigatableLabelBox#onInsert
is called). Default if false.
NavigatableLabelBox represents a label edit box which supports navigational keys It is sort of abstract in the sense and expects derived classes to implement real logic in onChange onNext onPrev etc . The derived class must call LabelBox#initLabelBox @constructoe @param { boolean } handleINSKey ( optional ) true if INS key should be handled ( and NavigatableLabelBox#onInsert is called ) . Default if false .
function NavigatableLabelBox (handleINSKey)
{
    this.setFocus = function() { 
	if( this.isEnabled() ) 
	    this.getTextBox().focus(); 
    }
    this.onEscape = function() { }
    this.onHome = function() { }
    this.onEnd = function() { }
    this.onNext = function() { }
    this.onPrev = function() { }
    this.onUp = function() {}
    this.onDown = function() {}
    this.onINS = function() {}
    this.onDelete = function() {return false;}
    this.onNextLine = function() {
    }
    this.onChange = function() { }
    this.onFocus = function() {
    }
    this.onBlur = function() {
    }
    this.onChar = function(cc) {
	    return false;
    }
    this.fKeyHandled = false;
    this.fLastContents = null;
    this.keydown = function(event)
    {
	var cc = Utils.getCharFromEvent(event);
	var handled = true;
	if( cc == 9 || cc == 13 || (!this.fSpacesAllowed && cc == 32) ) {
	    if( cc != 13 ) {
		if(cc == 8 || event.shiftKey == 1 )
		    this.onPrev();
		else
		    this.onNext();
	    }
	    else
		this.onNextLine();
	}
	else if( cc == 27 ) 
	    this.onEscape();
	else if( cc == 35 ) 
	    this.onEnd();
	else if( cc == 36 ) 
	    this.onHome();
	else if( cc == 37 ) 
	    this.onPrev();
	else if( cc == 38 ) 
	    this.onUp();
	else if( cc == 39 ) 
	    this.onNext();
	else if( cc == 40 ) 
	    this.onDown();
	else if( cc == 45  && this.fHandleINSKey )
	    this.onINS();
	else if( cc == 46 )  {
	    handled = this.onDelete();
	}
	else
	    handled = this.onChar(cc);
	this.fKeyHandled = handled;
	if( handled ) {
	    event.returnValue = false;
	    if( event.stop )
		event.stop();
	    if( event.preventDefault )
		event.preventDefault();
	    if( event.stopPropagation )
		event.stopPropagation();
	    return false;
	}
	this.fLastContents = this.getTextBox().value;
	return true;
    }
    function IE_textKeyDown() {
	this.fLabelBox.keydown(event);
    }
    this.IE_textKeyDown = IE_textKeyDown;
    this.keyup = function(event)
    {
	var cc = Utils.getCharFromEvent(event);
	if( !this.fKeyHandled ) {
	    var v = this.getTextBox().value;
	    if( v != this.fLastContents )
		this.onChange();
	}
    }
    function IE_textKeyUp() {
	this.fLabelBox.keyup(event);
    }
    this.IE_textKeyUp = IE_textKeyUp;
    function IE_textFocus() {
	this.fLabelBox.onFocus();
    }
    this.IE_textFocus = IE_textFocus;
    function IE_textBlur() {
	this.fLabelBox.onBlur();
    }
    this.IE_textBlur = IE_textBlur;
    this.initLabelBox = function(isSpacesAllowed) {
	this.fSpacesAllowed = isSpacesAllowed;
	this.getTextBox().fLabelBox = this;
	if( Utils.isIE()) {
	    this.getTextBox().onkeydown = IE_textKeyDown;
	    this.getTextBox().onkeyup   = IE_textKeyUp;
	    this.getTextBox().onfocus   = IE_textFocus;
	    this.getTextBox().onblur    = IE_textBlur;
	}
	else {
	    this.getTextBox().setAttribute('onkeydown','this.fLabelBox.keydown(event);');
	    this.getTextBox().setAttribute('onkeyup','this.fLabelBox.keyup(event);');
	    this.getTextBox().setAttribute('onfocus','this.fLabelBox.onFocus();');
	    this.getTextBox().setAttribute('onblur', 'this.fLabelBox.onBlur();');
	}
    }
    this.fSpacesAllowed = true;
    if( !handleINSKey ) handleINSKey = false;
    this.fHandleINSKey = handleINSKey;
}
function NavigatableLabelBox ( handleINSKey ) { this . setFocus = function ( ) { if ( this . isEnabled ( ) ) this . getTextBox ( ) . focus ( ) ; } this . onEscape = function ( ) { } this . onHome = function ( ) { } this . onEnd = function ( ) { } this . onNext = function ( ) { } this . onPrev = function ( ) { } this . onUp = function ( ) { } this . onDown = function ( ) { } this . onINS = function ( ) { } this . onDelete = function ( ) { return false ; } this . onNextLine = function ( ) { } this . onChange = function ( ) { } this . onFocus = function ( ) { } this . onBlur = function ( ) { } this . onChar = function ( cc ) { return false ; } this . fKeyHandled = false ; this . fLastContents = null ; this . keydown = function ( event ) { var cc = Utils . getCharFromEvent ( event ) ; var handled = true ; if ( cc == 9 || cc == 13 || ( ! this . fSpacesAllowed && cc == 32 ) ) { if ( cc != 13 ) { if ( cc == 8 || event . shiftKey == 1 ) this . onPrev ( ) ; else this . onNext ( ) ; } else this . onNextLine ( ) ; } else if ( cc == 27 ) this . onEscape ( ) ; else if ( cc == 35 ) this . onEnd ( ) ; else if ( cc == 36 ) this . onHome ( ) ; else if ( cc == 37 ) this . onPrev ( ) ; else if ( cc == 38 ) this . onUp ( ) ; else if ( cc == 39 ) this . onNext ( ) ; else if ( cc == 40 ) this . onDown ( ) ; else if ( cc == 45 && this . fHandleINSKey ) this . onINS ( ) ; else if ( cc == 46 ) { handled = this . onDelete ( ) ; } else handled = this . onChar ( cc ) ; this . fKeyHandled = handled ; if ( handled ) { event . returnValue = false ; if ( event . stop ) event . stop ( ) ; if ( event . preventDefault ) event . preventDefault ( ) ; if ( event . stopPropagation ) event . stopPropagation ( ) ; return false ; } this . fLastContents = this . getTextBox ( ) . value ; return true ; } function IE_textKeyDown ( ) { this . fLabelBox . keydown ( event ) ; } this . IE_textKeyDown = IE_textKeyDown ; this . keyup = function ( event ) { var cc = Utils . getCharFromEvent ( event ) ; if ( ! this . fKeyHandled ) { var v = this . getTextBox ( ) . value ; if ( v != this . fLastContents ) this . onChange ( ) ; } } function IE_textKeyUp ( ) { this . fLabelBox . keyup ( event ) ; } this . IE_textKeyUp = IE_textKeyUp ; function IE_textFocus ( ) { this . fLabelBox . onFocus ( ) ; } this . IE_textFocus = IE_textFocus ; function IE_textBlur ( ) { this . fLabelBox . onBlur ( ) ; } this . IE_textBlur = IE_textBlur ; this . initLabelBox = function ( isSpacesAllowed ) { this . fSpacesAllowed = isSpacesAllowed ; this . getTextBox ( ) . fLabelBox = this ; if ( Utils . isIE ( ) ) { this . getTextBox ( ) . onkeydown = IE_textKeyDown ; this . getTextBox ( ) . onkeyup = IE_textKeyUp ; this . getTextBox ( ) . onfocus = IE_textFocus ; this . getTextBox ( ) . onblur = IE_textBlur ; } else { this . getTextBox ( ) . setAttribute ( 'onkeydown' , 'this.fLabelBox.keydown(event);' ) ; this . getTextBox ( ) . setAttribute ( 'onkeyup' , 'this.fLabelBox.keyup(event);' ) ; this . getTextBox ( ) . setAttribute ( 'onfocus' , 'this.fLabelBox.onFocus();' ) ; this . getTextBox ( ) . setAttribute ( 'onblur' , 'this.fLabelBox.onBlur();' ) ; } } this . fSpacesAllowed = true ; if ( ! handleINSKey ) handleINSKey = false ; this . fHandleINSKey = handleINSKey ; }
NavigatableLabelBox
 represents a label edit box which supports navigational keys
 <p>
 It is sort of abstract in the sense and expects derived classes to implement
 real logic in onChange, onNext, onPrev etc.
NavigatableLabelBox represents a label edit box which supports navigational keys <p > It is sort of abstract in the sense and expects derived classes to implement real logic in onChange onNext onPrev etc .
/**
     * set focus to the edit box
     */ /**
     * (protected) called when escape is pressed
     * @private
     */ /**
     * (protected) called when key sequence for "home" is pressed
     * @private
     */ /**
     * (protected) called when key sequence for "end" is pressed
     * @private
     */ /**
     * (protected) called when key sequence for "next" is pressed
     * @private
     */ /**
     * (protected) called when key sequence for "prev" is pressed
     * @private
     */ /**
     * (protected) called when key sequence for up-arrow is pressed
     * @private
     */ /**
     * (protected) called when key sequence for down-arrow is pressed
     * @private
     */ /**
     * (protected) called when key sequence for INS key is pressed and
     * INS key should be handled
     * @private
     */ /**
     * (protected) called when key sequence for Delete key is pressed
     * @private
     */ /**
     * (protected) called when key sequence for "beginning of next line" is pressed
     * @private
     */ /**
     * (protected) called when contents have changed
     * @private
     */ /**
     * (protected) called when text box gets focus
     */ /**
     * (protected) called when text box looses focus
     */ /**
     * (protected) called when a non-navigational key is pressed
     * @param  cc	the character
     * @return true if key is handled and default processing should be foregone
     */ /**
     * did we handle last key pressed in keydown  - we do so only for
     * navigational keys
     * @type boolean
     * @private
     */ /**
     * called when a key is pressed in the edit box
     * @private
     */ // escape key
 // end key 
 // home key 
 // left key
 // up key 
 // right key 
 // down key 
 // TODO: IE only, others require stopDefault, stopPropagation
 // others are processed as default
 /**
     * key down handler for IE
     * @private
     */ /**
     * called when key is released
     * @private
     */ //if( (cc == 32 && this.fSpacesAllowed) || (cc > 32 && cc <= 126 ))
 /**
     * key released handler for IE
     */ /**
     * focus handler for IE
     */ /**
     * blur handler for IE
     */ /**
     *
     * (protected) to be called by derived class to initialize the control
     * @private
     * @param {boolean}  spacesAllowed 	are spaces allowed in label box (otherwise
     *					they act as navigational keys like tabs)
     */ // on IE. doing setAttribute doesnt work like we want
 /**
     * are spaces allowed in label box (otherwise they act as navigational keys like tabs)
     * @type boolean
     * @private
     */ /**
     * should we handle INS key?
     */