R: Vector doesn't change after addHandlerClicked is called (gWidgets)

45 Views Asked by At

I want to give a user a chance, to edit a vector - to add or to delete an element. I have a problem, because the vector doesn't change after user's action.

This is my code:

y <- c(1,2,3)
RO_window <- gwindow("Edit vector", visiable=TRUE) #, parent = MainWindow)
group <- ggroup(horizontal = FALSE, container =  RO_window)
tempRB <- gradio(y, container =group)
button1 <- gbutton("Delete", border = TRUE, container = group)
addHandlerClicked(button1, handler = function(h,...){
  x <- svalue(tempRB, index = TRUE)
  y <- y[! y %in% y[x]]
  print(y)
  return(y)
})

input_text <- gtext("", container = frame2, front.attr=list(style="bold"))   
button2 <- gbutton("Confirm", border = TRUE, container = group)
addHandlerClicked(button2, handler = function(h,...){
  y <- append(y, svalue(input_text))
  print(y)
  return(y)
})

When print(y) is called, vector is edited corectly, but when I use it outside the context of this code, it is the same as at the begining.

0

There are 0 best solutions below