gedit: gedit widget

Description Usage Arguments Value Methods Note Examples

Description

gedit widget

For the GEdit class, the change signal is "blur" or a focus-out event. Use the reference class method add_handler_enter for "enter" key press and add_handler_change for a mix of change events (browser dependent, but for most includes ['change', 'input', 'textInput', 'keyup', 'dragdrop'].

Usage

1
2
3
gedit(text = "", width = 25, coerce.with = NULL, initial.msg = "",
  handler = NULL, action = NULL, container = NULL, ..., ext.args = NULL,
  validate.type = NULL, validate.regexp = NULL)

Arguments

text

initial text

width

width in characters. Converted to pixels by multiplying by 8.

coerce.with

Function to call for coercion from text. If no coercion be careful when using the values, as the user can potentialy type in malicious things.

initial.msg

initial message to user, in greyed out text

handler

optional means (to addHandlerChanged) to specify a handler for the default signal. A handler is a function with signature (h,...) where h is a list with components obj referring to the object emitting the signal, action containing values passed to the action argument, and possible other values.

action

Passed to handler to parameterize a call

container

A parent container. In gWidgetsWWW2 a parent container is not optional (though it can be substituted with the parent argument in some circumstances). The parent specifies the widget heirarchy and the ... argument is used to pass along arguments to layout the child component in the parent container. Typically, these are passed to the add method of the parent container.

...

Used to pass along argument to the parent container's add method and possible other arguments to the underlying ference class constructors.

ext.args

The contructors of gWidgetsWWW2 ultimately call an Ext constructor. The options passed to the Ext constructor may be added to or overridden by use of this argument. Values are passed in as named list components and with values converted into JavaScript objects by asJSObject.

validate.type

pre-defined validation type: c("alpha","alphanum","numeric", "email","url","nonempty"). When specified, value is verified to match this type.

validate.regexp

optional regular expression to validate against. If the argument has a names argument, this is used to notify the user why the type is invalid.

Value

a GEdit referece class object

Methods

add_handler_enter(handler, action = NULL, ...)

add handler key for enter event. No addHandlerEnter method, call this directly

before_handler(signal, params)

Hook that can be called prior to observer call. Might be useful to set value without relying on transport call to arrive first. Return value – a named list – is passed to observers as components of h

process_transport(value, ...)

R Function to process the transport. Typically just sets 'value', but may do more. In the above example, where var param = value: this.getText() was from transport_fun we would get the text for value

Note

The 'change' event varies from browser to browser. To catch just an enter key, the add_handler_enter reference class method is available. There is no [<- method to add typeahead (autocomplete) values. This feature can be done with a combobox though.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
w <- gwindow()
sb <- gstatusbar("Powered by gWidgetsWWW2 and Rook", cont=w)
g <- ggroup(cont=w, horizontal=FALSE)
e <- gedit("initial text", cont=g)
addHandlerChanged(e, handler=function(h,...) {
galert(paste("You entered", svalue(h$obj)), parent=w)
})
## initial message
e1 <- gedit(initial.msg="type a value here ...", cont=g)
## validation
e2 <- gedit(cont=g, validate.regexp=setNames("^[a-z]*$", "Lower case only"))

jverzani/gWidgetsWWW2 documentation built on Feb. 9, 2020, 5:18 p.m.