gtext {gWidgets} | R Documentation

## Constructor for widget for multi-line editable text input

### Description

The `gtext` widget creates a text buffer for handling multiple lines of text.

### Usage

    gtext (text = NULL, width = NULL, height = 300, font.attr = NULL,
        wrap = TRUE, handler = NULL, action = NULL, container = NULL,
        ..., toolkit = guiToolkit())

### Arguments

`text` | Initial text in widget
`width` | Width of widget in pixels
`height` | Height of gtext widget in pixels
`font.attr` | Optional specification of font attributes
`wrap` | For gtext, are long lines wrapped?
`handler` | Handler called when text is changed.
`action` | Passed to handler
`container` | Optional container to attach widget to
`...` | Passed to add method of container
`toolkit` | Which GUI toolkit to use

### Details

The `gtext` widget has the following methods.

The `svalue` method returns the text held in the buffer. If `drop=TRUE`, then only the text in the buffer selected by the mouse is returned.

The `svalue<-` method replaces the text in the buffer with the new text.

New text is added with the `insert` method. The basic usage is `insert(obj,text)` where "text" could be a single line or a vector of text, or –for gWidgetsRGtk2 – a gwidget (although some, like gedit, are kind of flaky). Extra arguments include `do.newline` a logical indicating if a new line after the last line should be added (default is `TRUE`); `font.attr` to specify any font attributes; `where` indicating where to add the text (either `end` or `beginning`). The `insert` generic replaces the overused `add` for `gtext`, but `add` will still work.

The font can be changed. The `font.attr` argument to the constructon and to `add` specifies fonts using a namedcharacter vector. For instance `c(style="normal", weights="bold",sizes="medium")`. The command `obj[['tags']]` will produce a list containing all the available attributes.

The `font<-` method is used to change the font of the currently selected text. It too takes a named character vector specifying the font attributes.

The `dispose` method clears the text in the buffer.

The `addHandlerKeystroke` method for `gedit`and `gtext` is called for each keystroke. In `gtext` or `RGtk2` the component `key` of the `h` argument contains the keystroke.

### Examples

    ## Not run:
            ## gtext example
            obj <- gtext("First line", container=gwindow())
            insert(obj,"second line", font.attr=c(family="monospace"))
            insert(obj,"third line", font.attr=c(foreground.colors="red"))
    ## End(Not run)

[Package gWidgets version 0.0-39 Index]