gtext: Multiline text edit constructor

Description Usage Arguments Value Note Examples

View source: R/gtext.R

Description

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 class 'GText'
insert(
  obj,
  value,
  where = c("end", "beginning", "at.cursor"),
  font.attr = NULL,
  do.newline = TRUE,
  ...
)

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

## S3 method for class '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

Note

with gWidgetstcltk the allocation of size to the widget may be incorrect. It is best to wait until the widget is added before displaying its parent window. See the visible argument for gwindow.

Examples

1
2
3
4
5
6
7
8
9
## 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

## End(Not run)

gWidgets2 documentation built on Jan. 11, 2022, 1:07 a.m.