Once a callback is set with rgl.setMouseCallbacks, rgl.setMouseCallbacks( 1, NULL, NULL, NULL ) will not restore the default behavior. Is this a bug or a feature? Should I file an issue if it is a bug?
Setting a callback to NULL means "no handler". When the docs say NULL is "the default value", they are talking about the default value for this function, not the default mouse handler.
If you want to restore the default value, you would use par3d(mouseMode = r3dDefaults()$mouseMode).
If you want to restore the previous value (which might not be the default), you would need to save it and then restore it. For example,
# save old values
oldmode <- par3d("mouseMode")
oldhandlers <- rgl.getMouseCallbacks(button)
# set new values
rgl.setMouseCallbacks(button, begin=..., etc.)
.... use them for a while ....
# restore old values
do.call(rgl.setMouseCallbacks, c(list(button = button), oldhandlers))
par3d(mouseMode = oldmode)
Setting a callback to
NULLmeans "no handler". When the docs sayNULLis "the default value", they are talking about the default value for this function, not the default mouse handler.If you want to restore the default value, you would use
par3d(mouseMode = r3dDefaults()$mouseMode).If you want to restore the previous value (which might not be the default), you would need to save it and then restore it. For example,