Use whiteboard tools
After successfully joining an Interactive Whiteboard room, you can use the default tool to write and draw on the whiteboard. The Interactive Whiteboard SDK provides rich basic editing tools, such as pencil, arrow, straight line, eraser, and various shapes. In addition, the Interactive Whiteboard SDK supports modifying the font size, stroke width, and stroke color.
This page describes using whiteboard tools in the following ways:
- Directly set the whiteboard tool in the code. This method applies when you need only a simple editing tool.
- Implement a simple toolbar and switch whiteboard tools by clicking buttons. This method applies when you want to provide varied tools for users to choose from.
Understand the tech
The Interactive Whiteboard SDK provides the setMemberState
method for setting the whiteboard tools used in the current whiteboard room. By modifying the MemberState
properties of the current room, you can switch tools, select shapes, and change the font size, stroke width, and color.
The MemberState
type contains the following properties:
currentApplianceName
: The name of the whiteboard tool currently in use, which can be set as one of the following values:arrow
: Arrowclicker
: Clickerellipse
: Ellipseeraser
: Eraserhand
: HandlaserPointer
: Laser pointerpencil
: Pencilrectangle
: Rectangleselector
: Selector. If you set thefloatBar
property inJoinRoomParams
astrue
, when the user uses theselector
tool, a floating bar that provides more text editing options displays.shape
: Shape. When settingcurrentApplianceName
asshape
, you can setshapeType
to choose a shape; if you do not setshapeType
, the SDK usestriangle
by default.straight
: Straight linetext
: Text. If you set thefloatBar
property inJoinRoomParams
astrue
, when the user uses thetext
tool, a floating bar that provides more text editing options displays.
shapeType
: (Optional) The shape type, which can be set as one of the following values:pentagram
: Pentagramrhombus
: RhombusspeechBalloon
: Speech balloontriangle
: Triangle
strokeColor
: The stroke color in RGB format. For example,[0,0,255]
represents blue.strokeWidth
: The stroke width. This parameter does not take effect for text.textSize
: The font size. This parameter takes effect only for text.
Prerequisites
To follow the procedure on this page, ensure that you have integrated the Interactive Whiteboard SDK into your project and implemented joining a room. For details, see Join the Whiteboard Room.
Set the whiteboard tool in the code
You can directly set the whiteboard tool used in the current room in the program. This section uses the Join the Whiteboard Room sample code as an example.
Add the following code to the joinWhiteboard.js
file:
Save the changes, and refresh the index.html
page. Now you can click and drag the mouse to draw a pink rectangle on the whiteboard.
To change the whiteboard tool, you can modify the newly added code as follows:
Save the changes, and refresh the index.html
page. Now you can click and drag the mouse to draw a blue pentagram on the whiteboard.
Switch whiteboard tools through the UI
In scenarios where you want to offer multiple whiteboard tools and switch the tool based on a user's choice, you can design and implement a toolbar.
This section extends the Join the Whiteboard Room sample code to show the implementation of a simple toolbar.
- Add the following code to the
joinWhiteboard.js
file:
- Add the following code to the
index.html
file to display the toolbar on the web page:
Save the changes, and refresh the index.html
page. The following toolbar displays in the lower left corner of the page. You can click any button and use the corresponding tool to write and draw on the whiteboard.
Reference
More whiteboard tools
In addition to the basic editing tools listed in the Understand the tech section, the Interactive Whiteboard SDK provides additional editing functions through the following methods:
Methods | Description |
---|---|
copy | Copies the selected content. |
paste | Pastes the copied content. |
duplicate | Duplicates the selected content. |
delete | Deletes the selected content. |
redo | Redoes an undone action. |
undo | Undoes an action. |
disableeraseimage | Disables the eraser from erasing images on the whiteboard. |
disabledeviceinputs | Disables the whiteboard from responding to users' operations. |
These methods, which are also members of the Room
interface, also do not have user interfaces provided by the SDK. You can implement these functions by designing a UI and calling the corresponding methods according to your business needs.