addTkBind: Add Tk Binds

Description Usage Arguments Details Examples

View source: R/functions.R

Description

Add binds to previous defined bindings

Usage

1
addTkBind(win, event, fun = NULL)

Arguments

win

window

event

event

fun

a function

Details

This function adds a new bind while keeping the previous defined binds.

Examples

 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
## Not run: 

tt <- tktoplevel()
tt <- tkRplot(tt, function () plot(1:10))
FUN <- local({
  canPos <-.Tcl(paste(tt$env$canvas, "create text 0 0 "))
    function (x, y) {
        x <- as.numeric(x)
        y <- as.numeric(y)
       tkdelete(tt$env$canvas, tclvalue(canPos))
           xy <- formatC(tk2usr(x, y),
                   digits = 2,
                     format = "f",
                       width = 5)
    canPos <<- .Tcl(
     paste(tt$env$canvas, "create text 40 10 -fill blue -justify left -text { ",
            xy[1], " ", xy[2],
            "} -font {Helvetica -10}"))
  }})

tkbind(tt$env$canvas, "<Motion>", FUN)
tkbind(tt$env$canvas, "<Motion>") #to give current bidings
FUN1 <- function (x,y) print(tk2usr(x,y))
addTkBind(tt$env$canvas, "<Motion>", FUN1)
tkbind(tt$env$canvas, "<Motion>") #to give current bidings

## End(Not run)

tkRplotR documentation built on June 27, 2021, 5:08 p.m.