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"
)

Arguments

id

R3dmol id or a r3dmol object (the output from r3dmol()).

name

Name for button.

label

Label for button.

func

The function executed when the button is clicked.

align_items

The css align-items property specifies the default alignment for items inside the viewer.

justify_content

The css justify-content property aligns the buttons when the items do not use all available space on the main-axis (horizontally).

Value

R3dmol id or a r3dmol object (the output from r3dmol())

Details

If more than one button is set, only the layout (justify-content and align-items) of the first button will be used.

Examples

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();
      }
    "
  )