61 TextEntryControl.prototype.init = function(id, caption) { |
61 TextEntryControl.prototype.init = function(id, caption) { |
62 uiLogger.debug("TextEntryControl.init(" + id + ", " + caption + ")"); |
62 uiLogger.debug("TextEntryControl.init(" + id + ", " + caption + ")"); |
63 |
63 |
64 // call superclass initializer |
64 // call superclass initializer |
65 Control.prototype.init.call(this, id, caption); |
65 Control.prototype.init.call(this, id, caption); |
66 } |
66 }; |
67 |
67 |
68 // Common event listeners hookup function called from subclasses. |
68 // Common event listeners hookup function called from subclasses. |
69 TextEntryControl.prototype.bindTextEntryControlListeners = function() { |
69 TextEntryControl.prototype.bindTextEntryControlListeners = function() { |
70 var self = this; |
70 var self = this; |
71 this.peerElement.addEventListener("focus", function() { self.focusStateChanged(true); }, false); |
71 this.peerElement.addEventListener("focus", function() { self.focusStateChanged(true); }, false); |
72 this.peerElement.addEventListener("blur", function() { self.focusStateChanged(false); }, false); |
72 this.peerElement.addEventListener("blur", function() { self.focusStateChanged(false); }, false); |
73 this.peerElement.addEventListener("mouseover", function() { self.hoverStateChanged(true); }, false); |
73 this.peerElement.addEventListener("mouseover", function() { self.hoverStateChanged(true); }, false); |
74 this.peerElement.addEventListener("mouseout", function() { self.hoverStateChanged(false); }, false); |
74 this.peerElement.addEventListener("mouseout", function() { self.hoverStateChanged(false); }, false); |
75 this.peerElement.addEventListener("change", function() { self.valueChanged(); }, false); |
75 this.peerElement.addEventListener("change", function() { self.valueChanged(); }, false); |
76 } |
76 }; |
77 |
77 |
78 // Returns the enabled state. |
78 // Returns the enabled state. |
79 // Override this in subclasses as required to implement the state change. |
79 // Override this in subclasses as required to implement the state change. |
80 TextEntryControl.prototype.isEnabled = function() { |
80 TextEntryControl.prototype.isEnabled = function() { |
81 return !this.peerElement.readOnly; |
81 return !this.peerElement.readOnly; |
82 } |
82 }; |
83 |
83 |
84 // Sets the enabled state. |
84 // Sets the enabled state. |
85 // Override this in subclasses as required to implement the state change. |
85 // Override this in subclasses as required to implement the state change. |
86 TextEntryControl.prototype.setEnabled = function(enabled) { |
86 TextEntryControl.prototype.setEnabled = function(enabled) { |
87 uiLogger.debug("TextEntryControl.setEnabled(" + enabled + ")"); |
87 uiLogger.debug("TextEntryControl.setEnabled(" + enabled + ")"); |
88 this.peerElement.readOnly = !enabled; |
88 this.peerElement.readOnly = !enabled; |
89 // update the style |
89 // update the style |
90 this.updateStyleFromState(); |
90 this.updateStyleFromState(); |
91 } |
91 }; |
92 |
92 |
93 // Returns the control text. |
93 // Returns the control text. |
94 TextEntryControl.prototype.getText = function() { |
94 TextEntryControl.prototype.getText = function() { |
95 return this.peerElement.value; |
95 return this.peerElement.value; |
96 } |
96 }; |
97 |
97 |
98 // Sets the text for the control. |
98 // Sets the text for the control. |
99 TextEntryControl.prototype.setText = function(text) { |
99 TextEntryControl.prototype.setText = function(text) { |
100 this.peerElement.value = text; |
100 this.peerElement.value = text; |
101 } |
101 }; |
102 |
102 |
103 // Returns the focusable state for the control. |
103 // Returns the focusable state for the control. |
104 TextEntryControl.prototype.isFocusable = function() { |
104 TextEntryControl.prototype.isFocusable = function() { |
105 // text entry controls are always focusable |
105 // text entry controls are always focusable |
106 return true; |
106 return true; |
107 } |
107 }; |
108 |
108 |
109 // Sets the focused state for the control. |
109 // Sets the focused state for the control. |
110 // Note: This may not always succeed. |
110 // Note: This may not always succeed. |
111 TextEntryControl.prototype.setFocused = function(focused) { |
111 TextEntryControl.prototype.setFocused = function(focused) { |
112 uiLogger.debug("TextEntryControl.setFocused(" + focused + ")"); |
112 uiLogger.debug("TextEntryControl.setFocused(" + focused + ")"); |
113 if (focused) { |
113 if (focused) { |
114 this.peerElement.focus(); |
114 this.peerElement.focus(); |
115 } else { |
115 } else { |
116 this.peerElement.blur(); |
116 this.peerElement.blur(); |
117 } |
117 } |
118 } |
118 }; |
119 |
119 |
120 // Callback for value change events. |
120 // Callback for value change events. |
121 TextEntryControl.prototype.valueChanged = function() { |
121 TextEntryControl.prototype.valueChanged = function() { |
122 uiLogger.debug("TextEntryControl.valueChanged()"); |
122 uiLogger.debug("TextEntryControl.valueChanged()"); |
123 // notify event listeners |
123 // notify event listeners |
124 this.fireEvent(this.createEvent("ValueChanged", this.peerElement.value)); |
124 this.fireEvent(this.createEvent("ValueChanged", this.peerElement.value)); |
125 } |
125 }; |