behavior: edit

Standard single line input element behavior

Elements

that have this behavior applied by default (see master_style_sheet):

  • <input type=“text” /> - inline single line
  • <widget type=“text”></widget>

Attributes

that this behavior knows about:

  • value=“text” - initial value of the input element
  • size=integer - determines value of (intrinsic and default) width of the element.
  • maxlength=integer - maximum number of characters that this element can contain.
  • filter=“filter-expr” - limits set of characters allowed to input in the field. filter-expr string accepts single characters and character ranges. Example: ”.@0~9a~zA~Z” - all alpha-numeric characters, '.' and '@'. If you just want to exclude some characters then you can prepend filter with '^' sign. So this filter=“^.,-” filter will allow to input any character except '.', ',' and '-'.
  • novalue=“text” - if textbox is empty then it shows text provided by the novalue attribute. You can style this state by using :empty CSS selector.

Events

Together with the standard set of events (mouse, keyboard, focus) behavior: button generates:

  • EDIT_VALUE_CHANGED event - value of the element was changed due to user actions. Posted (asynchronous) event.
  • EDIT_VALUE_CHANGING event - sent when value of the element is about to change. Synchronous event.

Value

type json::value::V_STRING, reflects current status of internal editing buffer.

Special key combinations

  • LEFT, CTRL+LEFT, SHIFT+LEFT, CTRL+SHIFT+LEFT
  • RIGHT, CTRL+RIGHT, SHIFT+RIGHT, CTRL+SHIFT+RIGHT
  • HOME, SHIFT+HOME
  • END, SHIFT+END
  • BACKSPACE, ALT+BACKSPACE, CTRL+BACKSPACE
  • CTRL+A
  • DELETE, SHIFT+DELETE, CTRL+DELETE
  • INSERT, SHIFT+INSERT, CTRL+INSERT
  • CTRL+X
  • CTRL+V
  • CTRL+Z
  • CTRL+(LEFT)SHIFT and CTRL+(RIGHT)SHIFT - for subtrees under dir attribute these key combinations set dir=“ltr” and dir=“rtl” correspondingly.

Methods

Edit supports following xcall() methods (see dom::element::xcall() function):

  • xcall(“selectionStart”): int - return selection starting position;
  • xcall(“selectionEnd”): int - return selection ending position;
  • xcall(“setSelection”, start:int, end:int):void - sets position of the selection in the edit field;
  • xcall(“selectionText”): string - returns selected text;
  • xcall(“insertText”, text: string):void - inserts text at caret position;
  • xcall(“appendText”, text: string):void - appends text;
  • xcall(“undo”, false): bool - returns boolean wrapped into json::value, true - if undo is available and false if not;
  • xcall(“undo”, true) - executes undo operation;
  • xcall(“cut”, false): bool - returns true - if cut is available and false if not;
  • xcall(“cut”, true) - executes cut operation - copy selection into the clipboard and deletes selected text;
  • xcall(“copy”, false): bool - returns true - if copy is available and false if not;
  • xcall(“copy”, true) - executes copy operation - copy selection into the clipboard;
  • xcall(“paste”, false): bool - returns true - if paste is available and false if not;
  • xcall(“paste”, true) - executes paste operation - pastes content of the the clipboard;
  • xcall(“selectAll”): bool - returns true if current selection spans the whole document and false otherwise.
  • xcall(“selectAll”, true) - selects whole content of the editor;

Note that in Sciter you can access these methods simply as:

  var edit = self.select("input[type='text']");
  edit.setSelection(0,10);
  var selStart = edit.selectionStart;

h-smile/built-in-behaviors/edit.txt · Last modified: 2009/11/07 23:28 by andrew
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0