Best way to combine widgets

The rgl::rglwidget() function creates an htmlwidget that displays nicely in the RStudio viewer pane or an RMarkdown document. The package also includes some other functions to create controls to work with an rgl widget, and in many cases pipes can be used to combine these into one object, e.g.

rglwidget() %>% rglMouse()

displays a scene and a select control to control how the mouse works within the scene. Internally, these are returned as a browsable tagList using something like

htmltools::browsable(htmltools::tagList(rglwidget(), rglMouse()))

The problem is with the sizing. Once an rgl widget is put in a tagList, its size doesn't adapt to its container, so it's typically too big in the RStudio viewer. I can fix the size to a number of pixels, but I can't seem to find a way to say something like width="100%", height="80%" in the rgl widget to leave room for the selection control.

What's the best way to specify sizing for an rgl widget that would survive being put in a tagList?

After a bit of research, it appears that the manipulateWidgets::combineWidgets function is the thing I need to use.

1 Like