OMD Documentation

omdToolbar

Provides a visual toolbar UI for applying mathematical operations and functions to an omdEquationSequenceNode in the OMD system. The toolbar is rendered as an SVG group and supports operations like add, subtract, multiply, divide, and function application (e.g., sqrt, cos, etc.). It features dynamic popups for selecting operations and inputting values.

Class Definition

export class omdToolbar

Constructor

new omdToolbar(parentContainer, sequence, [options])

Creates an instance of the omdToolbar.

Public Properties

Public Methods

setInputText(text)

Sets the text displayed in the middle input button and updates the internal inputValue state. It also adjusts the font size of the button's text element for better centering.

destroy()

Cleans up the toolbar component by removing its SVG elements from the DOM and clearing internal references.

Internal Methods

Example

import { omdToolbar } from '@teachinglab/omd';
import { omdEquationSequenceNode } from '@teachinglab/omd';
import { omdEquationNode } from '@teachinglab/omd';

// Create an SVG container (e.g., from jsvgContainer)
// const svgContainer = new jsvgContainer();
// document.body.appendChild(svgContainer.svgObject);

// Create an initial sequence
const initialEquation = omdEquationNode.fromString('2x + 5 = 15');
const sequence = new omdEquationSequenceNode([initialEquation]);

// Create the toolbar and add it to the SVG container
const toolbar = new omdToolbar(svgContainer, sequence, {
  x: 50, // Position the toolbar
  y: 50,
  showUndoButton: true, // Enable the undo button
  styles: { // Example of structured styling
    backgroundColor: '#34495e',
    buttonColor: '#ecf0f1',
    popupBackgroundColor: '#bdc3c7',
    borderRadius: 10
  }
});

// Interact with the toolbar to apply operations to the sequence.
// For example, click the '-' button and enter '5' to subtract 5 from both sides.

Notes

See Also

↑ Top