I'd like to allow users to edit data in tcltk tables and to use vcmd to
validate data entry, e.g., not allowing non-numbers to be entered in
numeric cells and not allowing '\n' to be entered in text cells.

The problem is that I can't figure out how to "see" their data entry before
it is entered, although it looks like %S can be somehow used in vcmd to get
this information.

Example: to disallow '\n' to be entered into a cell in an editable table:

require(tcltk2)
tt<-tktoplevel(); tfr<-tkframe(tt); tkgrid(tfr)
tableData<-tclArray()
tableData[[0,0]]<-"junk"

CellValidation<-function(){

## http://www.tcl.tk/community/hobbs/tcl/capp/tkTable/tkTable.html says:
## *%S* For *ValidateCommand*, it is the potential new value of the cell
being validated.
## which is exactly what I want, but I can't figure out how to do that.
## The following allows one bad character and then disallows further edits

  testval<-tclvalue(tcl(table1,"curvalue"))

  if (length(grep("\n",testval))>0)  return(tcl("expr", FALSE))  else
 return(tcl("expr", TRUE))
}

table1<<-tk2table(tfr,
  rows=1,cols=1,
  selectmode="extended",
  variable=tableData,
  validate=T,
  vcmd=CellValidation
)

tcl(table1,"tag","configure", "active", fg='black',bg=colors()[411])
tkgrid(table1)

How can I get the %S value rather than the tcl(table1,"curvalue")?

Much thanks for any help.

-Dan

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to