handleMouseEvent method
Handles mouse events for dragging the slider thumb.
Implementation
void handleMouseEvent(MouseEvent event, int localX, int localY, Rect area) {
if (event.type != MouseEventType.press &&
event.type != MouseEventType.drag) {
return;
}
if (axis == SliderAxis.horizontal) {
if (localY != 0) return;
final trackLength = area.width;
if (trackLength <= 1) return;
final percent = (localX / (trackLength - 1)).clamp(0.0, 1.0);
value = min + percent * (max - min);
onChanged?.call(value);
} else {
if (localX != 0) return;
final trackLength = area.height;
if (trackLength <= 1) return;
// For vertical slider, top (y=0) is max, bottom (y=height-1) is min
final percent = 1.0 - (localY / (trackLength - 1)).clamp(0.0, 1.0);
value = min + percent * (max - min);
onChanged?.call(value);
}
}