selectTool method
void
selectTool(
- Offset point
)
Implementation
void selectTool(Offset point) {
debugPrint('DrawingToolManager.selectTool at $point');
_clearSelection();
// 从上到下检测点击的工具
for (int i = _tools.length - 1; i >= 0; i--) {
final tool = _tools[i];
if (tool.isVisible && tool.hitTest(point)) {
_selectedTool = tool;
_selectedTool!.state = DrawingToolState.selected;
// 更新当前颜色和线条粗细为选中工具的属性
_currentColor = _selectedTool!.color;
_currentStrokeWidth = _selectedTool!.strokeWidth;
onToolSelected?.call(_selectedTool);
debugPrint('选中工具: ${tool.type}, id: ${tool.id}');
_notifyToolsChanged();
break;
}
}
}