2

I'm using a tktext element with tcltk package in R. I would like to achieve that when you press the Tab Key a custom function gets executed but no actual tab space added to text.

Using tkbind(tkTextField, "<Tab>", function(x) {tabFunction(tkTextField)}) I can get the custom function executed but the "\t" is still inserted in the text. With tkbind(feldInp, "<Tab>", "break") the Tab is omitted but no function is executed.

How can I combine both?

StanW
  • 93
  • 5

1 Answers1

2

You could add a break after binding your own function, like so

library(tcltk2)

window <- tktoplevel()

window$env$txt <- tk2text(window, width = 60, height = 10)
tkpack(window$env$txt, fill = "both", expand = TRUE)

tkinsert(window$env$txt, "1.0", "Text")

tkbind(window$env$txt, "<Tab>", {function(x)tabFunction(window$env$txt)})
tkbind(window$env$txt, "<Tab>", "+ break")

tabFunction <- function(x) print("Message")
erocoar
  • 5,723
  • 3
  • 23
  • 45