Adding a ToolButton is done similar to adding a standard Button.
You first add the ToolButton and then you specify the behaviour and the visuals of the button.
Here is an example:
'First we add the control, the toolbuttonnCtrlIdx = RBNGroupAddControl("DTRegionAdd", "Add to Region", "", ControlType_ToolButton, TAB_SPATIAL, TAB_GROUP_SPATIAL_EDIT)If nCtrlIdx > 0 Then 'Then we design the visuals and the behaviour 'Create & Set the button tooltip Call RBNControlSetToolTipIdx(nCtrlIdx, "DrawTools", "Add extra region to the selected region.", "Select a polygon from the editable layer.") 'Set the button icon Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE, "", ApplicationDirectory$() & "Images\PolygonAdd_32.png") 'The DrawMode and Cursor are specific to the ToolButton 'Set DrawMode Call RBNControlSetDrawModeIdx(nCtrlIdx, DM_CUSTOM_POLYGON) 'Set Cursor Call RBNControlSetMICursorIdx(nCtrlIdx, MI_CURSOR_CROSSHAIR, "") 'Set Custom MapBasic Handle to the button Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "DTRegionAdd")End If
In the case above, we add the ToolButton to the Edit group on the SPATIAL tab. To use the defines I use here, you need to include the file RibbonElements.def that also is included in the mbLibrary on Github.
We set the drawmode to Polygon and the cursor to a standard Crosshair cursor.