m_button {r3dmol} | R Documentation |
Add button into viewer
Description
Add additional buttons to the viewer and 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.
Usage
m_button(
id,
name,
label,
func,
align_items = "flex-start",
justify_content = "flex-start"
)
Arguments
id |
R3dmol |
name |
Name for button. |
label |
Label for button. |
func |
The function executed when the button is clicked. |
align_items |
The css |
justify_content |
The css |
Details
If more than one button is set, only the layout
(justify-content
and align-items
) of the first button will be
used.
Value
R3dmol id
or a r3dmol
object (the output from
r3dmol()
)
Examples
library(r3dmol)
r3dmol() %>%
m_add_model(data = pdb_1j72, format = "pdb") %>%
m_zoom_to() %>%
m_button(
name = "cartoon",
label = "Cartoon",
align_items = "flex-end",
justify_content = "center",
func = "
function() {
viewer.setStyle({cartoon:{}});
viewer.render();
}
"
) %>%
m_button(
name = "stick",
label = "Stick",
func = "
function() {
viewer.setStyle({stick:{}});
viewer.render();
}
"
)