pergola.Input

This class replaces and extends the valueInputBox class of previous versions. It now takes keyboard input. It also implements a flexible mechanism allowing the callback function to be invoked as a method of this owner object, or of this.

class

prototype

PROPERTIES

String – it can be one of "string" "number" "date" "boolean". In practice only "number" and "date" are processed to invoke the appropriate formatting methods (format_number() or format_date()) if this format is true. Those methods use the JavaScript Intl built-in object, where available.

hasButtons

false – boolean; determines whether this should have inc and dec buttons; if true this is a spinner control.

realTime

false – boolean; if this hasButtons, determines whether the value should be applied in real time, or upon button release. You shouldn't use real time if the input has formatting options.

format

false – boolean; if true, the text node of this element is formatted with the method relative to this type. This type and the value of this value are not changed.

pergola.Key.keypress class method – you can override with one of the filtering methods provided by the Key class, or with your own keypress callback. Learn more in the SVG magazine Keyboard Class article.

true – boolean; the x and y attributes of this rect are set to 0.5 and therefore the left and top borders are not clipped by this container (svg). If this property is overridden, the x and y attributes of this rect are set to -0.5, and this can be sought in a lineup of input boxes (like a datagrid for example) to prevent double strokes.

"font-family"

0 – number (user space units). Unless overridden, the "font-family" attribute is not set and is inherited from the parent container, or the document. This allows to save some valuable DOM populating time when dealing with a great number of input instances in a read/write datagrid, for example.

"font-size"

0 – number (user space units). Overrides the value inherited by pergola.Class superclass. Unless overridden, the "font-size" attribute is not set and is inherited from the parent container, or the document. This allows to save some valuable DOM populating time when dealing with a great number of input instances in a read/write datagrid, for example.

METHODS

setValue()

Checks if this value length exceeds this inc.maxLength; updates this element data; sets input cursor position; if this realTime is true, invokes this fn as a method of this owner. You don't normally need to invoke this method explicitly.

increment()

Callback for this inc.buttontimer. You don't normally need to invoke this method explicitly.

decrement()

Callback for this dec.buttontimer. You don't normally need to invoke this method explicitly.

reset()

Resets this value to this baseValue; updates this element data. You don't normally need to invoke this method explicitly.

String. The name of a property of this target to which this value is applied.

inputCursor

Assigned dynamically by pergola.Key (instantiated in handleEvent) unless cursor is specifically set to false in the initialization object. This means that the input cursor is assigned by default, and for the odd case where you don't need it you must specify

If specified, an object defining the required textNode string property, optional x, y number (user space units) properties, and optional position string property. These are pergola.Caption properties. This property is reassigned during processing, and references a new pergola.Caption instance.

appendix

If specified, object defining the required textNode string property, and the optional x, and y number (user space units) properties. New pergola.Caption instance positioned to the right of the input box (for showing unit types for example). The pergola.Captionposition instance property is then set to "right" and cannot be overridden.

max

If specified, a number representing the upper threshold for numeric values.

min

If specified, number representing the lower threshold for numeric values.

maxLength

If specified, number representing the maximum string length allowed for this value.

If specified, an object as specified by Intl.NumberFormat options (see Mozilla's Intl.NumberFormat for a more friendly language) for formatting fields of type "number", or Intl.DateTimeFormat options (see Mozilla's Intl.DateTimeFormat for a more friendly language) for formatting fields of type "date".

fn

String specifying a method name. Note that for this class (exception), fn must be a string specifying the name of a method; this allows it to be invoked as a method of this owner, if owner is specified, or of this.

callback

If specified, it is a function or an object specifying keydown and/or keypress and/or keyup function properties, for the purpose of overriding any or all the default pergola.Key class methods.