Add additional buttons to the viewer and manually pass in JavaScript functions to enable additional actions to be done when the button is clicked (such as styling changes to the model). You can also use css flex layout to control the layout of all added buttons.
m_button_manual(
id,
name,
label,
func,
align_items = "flex-start",
justify_content = "center"
)R3dmol id or a r3dmol object (the output from
r3dmol()).
Name for button.
Label for button.
The function executed when the button is clicked.
The css align-items property specifies the default
alignment for items inside the viewer.
The css justify-content property aligns the
buttons when the items do not use all available space on the main-axis
(horizontally).
R3dmol id or a r3dmol object (the output from
r3dmol())
If more than one button is set, only the layout
(justify-content and align-items) of the first button will be
used.
library(r3dmol)
r3dmol() %>%
m_add_model(data = pdb_1j72, format = "pdb") %>%
m_zoom_to() %>%
m_button_manual(
name = "cartoon",
label = "Cartoon",
align_items = "flex-end",
justify_content = "center",
func = "
function() {
viewer.setStyle({cartoon:{}});
viewer.render();
}
"
) %>%
m_button_manual(
name = "stick",
label = "Stick",
func = "
function() {
viewer.setStyle({stick:{}});
viewer.render();
}
"
)