Class: SC.FieldView
Extends
SC.Control, SC.Validatable, SC.View.
Base view for managing a view backed by an input element. Since the web browser provides native support for editing input elements, this view provides basic support for listening to changes on these input elements and responding to them.
Generally you will not work with a FieldView directly. Instead, you should
use one of the subclasses implemented by your target platform such as
SC.CheckboxView
, SC.RadioView
, SC.TextFieldView
, and so on.
Defined in: field.js
- Since:
- SproutCore 1.0
Field Summary
- Fields borrowed from SC.View:
- acceptsMultitouch, ariaHidden, ariaRole, attributeBindings, autoMixins, backgroundColor, childViewLayout, childViewLayoutOptions, childViews, childViewsNeedLayout, classNameBindings, classNames, concatenatedProperties, createdByParent, designMode, displayProperties, enabledState, firstKeyView, hasLayout, hasTouch, hasVisibility, isBuildingIn, isBuildingOut, isChildViewLayoutLive, isEnabled, isFixedHeight, isFixedPosition, isFixedSize, isFixedWidth, isKeyResponder, isTextSelectable, isView, isVisible, lastKeyView, layerLocationNeedsUpdate, layerNeedsUpdate, layout, modeAdjust, nextKeyView, page, pane, parentView, previousKeyView, renderDelegateName, shouldInheritCursor, shouldInheritEnabled, tagName, themeName, toolTip, touchBoundary, transitionAdjust, transitionAdjustOptions, transitionHide, transitionHideOptions, transitionIn, transitionInOptions, transitionOut, transitionOutOptions, transitionShow, transitionShowOptions, useStaticLayout
- Fields borrowed from SC.Responder:
- hasFirstResponder, isFirstResponder, responderContext
- Fields borrowed from SC.Object:
- isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
- Fields borrowed from SC.Control:
- controlSize, errorLabel, fieldKey, fieldLabel, isActive, isControl, isSelected
Instance Methods
- $input()
- acceptsFirstResponder()
- didCreateLayer()
- fieldValue()
- fieldValueDidChange(partialChange)
- getFieldValue()
- keyDown(evt)
- mouseDown(evt)
- mouseEntered(evt)
- mouseExited(evt)
- mouseUp(evt)
- setFieldValue(newValue)
- willDestroyLayer()
Instance Method Detail
Override to return an CoreQuery object that selects the input elements
for the view. If this method is defined, the field view will
automatically edit the attrbutes of the input element to reflect the
current isEnabled
state among other things.
Override of SC.Responder.prototype.acceptsFirstResponder.
Tied to the isEnabledInPane
state.
SC.View
view state callback.
After the layer is created, set the field value and begin observing change events on the input field.
fieldisMouseDown: NO
,
/** The raw value of the field itself. This is computed from the 'value' property by passing it through any validator you might have set. This is the value that will be set on the field itself when the view is updated.
Your class should call this method anytime you think the value of the input element may have changed. This will retrieve the value and update the value property of the view accordingly.
If this is a partial change (i.e. the user is still editing the field and
you expect the value to change further), then be sure to pass YES
for the
partialChange
parameter. This will change the kind of validation done on
the value. Otherwise, the validator may mark the field as having an error
when the user is still in mid-edit.
Override to retrieve the actual value of the field.
The default implementation will simply retrieve the value attribute from the first input tag in the receiver view.
- Returns:
- String
- value
SC.RootResponder
event handler.
Simply allow keyDown
& keyUp
to pass through to the default web browser
implementation.
- Parameters:
- evt
SC.RootResponder
event handler.
Allow the browser to do its normal event handling for the mouse down
event. But first, set isActive
to YES
.
- Parameters:
- evt
SC.RootResponder
event handler.
If mouse was down and we renter the button area, set the active state again.
- Parameters:
- evt
SC.RootResponder
event handler.
Remove the active class on mouseExited
if mouse is down.
- Parameters:
- evt
SC.RootResponder
event handler.
On mouse up, remove the isActive
class and then allow the browser to do
its normal thing.
- Parameters:
- evt
Override to set the actual value of the field.
The default implementation will simple copy the newValue
to the value
attribute of any input tags in the receiver view. You can override this
method to provide specific functionality needed by your view.
- Parameters:
- newValue Object
- the value to display.
- Returns:
- SC.FieldView
- receiver
SC.View
state callback.
Removes the change event from the input field.