Learn R Programming

gWidgets2 (version 1.0-9)

gtext: Multiline text edit constructor

Description

The multiline text widget has its main property the text contained within.

  • The svalue will return a string (length-1 character vector) with embedded newlines

  • The "change" handler is addHandlerKeystroke

  • Use addHandlerSelectionChanged to monitor the selection

The svalue method for a gtext object returns a) the buffers content; b) the selected text (if drop=TRUE, but not NULL), this can be used to set the selected value, as well; c) the index of the selection if index=TRUE.

Usage

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

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

insert( obj, value, where = c("end", "beginning", "at.cursor"), font.attr = NULL, do.newline = TRUE, ... )

# S3 method for GText insert( obj, value, where = c("end", "beginning", "at.cursor"), font.attr = NULL, do.newline = TRUE, ... )

# S3 method for GText dispose(obj, ...)

# S3 method for GText svalue(obj, index = NULL, drop = NULL, ...)

Arguments

text

initial text

width

width of widget

height

height of widget (when width is specified)

font.attr

font attributes for text buffer. One can also specify font attributes for insertion. The font attributes are specified with a list with named components, with names and values coming from:

weight

in c("light", "normal", "bold", "heavy")

style

inc("normal", "oblique", "italic")

family

in c("sans", "helvetica", "times", "monospace")

size

in c("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large")

foreground

a value in colors()

background

a value in colors()

wrap

logical do lines wrap

handler

A handler assigned to the default change signal. Handlers are called when some event triggers a widget to emit a signal. For each widget some default signal is assumed, and handlers may be assigned to that through addHandlerChanged or at construction time. Handlers are functions whose first argument, h in the documentation, is a list with atleast two components obj, referring to the object emitting the signal and action, which passes in user-specified data to parameterize the function call.

Handlers may also be added via addHandlerXXX methods for the widgets, where XXX indicates the signal, with a default signal mapped to addHandlerChanged (cf. addHandler for a listing). These methods pass back a handler ID that can be used with blockHandler and unblockHandler to suppress temporarily the calling of the handler.

action

User supplied data passed to the handler when it is called

container

A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.)

...

These values are passed to the add method of the parent container. Examples of values are expand, fill, and anchor, although they're not always supported by a given widget. For more details see add. Occasionally the variable arguments feature has been used to sneak in hidden arguments to toolkit implementations. For example, when using a widget as a menubar object one can specify a parent argument to pass in parent information, similar to how the argument is used with gaction and the dialogs.

toolkit

Each widget constructor is passed in the toolkit it will use. This is typically done using the default, which will lookup the toolkit through guiToolkit.

obj

object

value

text to insert

where

position of insertion

do.newline

logical add a newline at end

index

NULL or logical. If TRUE and widget supports it an index, instead of a value will be returned.

drop

NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means.

Value

called for side effect

Examples

Run this code
# NOT RUN {
w <- gwindow("gtext example", visible=FALSE)
g <- gvbox(cont=w)
t1 <- gtext("initial text", container=g)
t2 <- gtext("monospace", font.attr=list(family="monospace"), container=g)
insert(t2, "new text in bold", font.attr=list(weight="bold"))
visible(w) <- TRUE
# }

Run the code above in your browser using DataLab