@@ -899,6 +899,8 @@ class WorkspaceProvider extends StateHandler {
899899 return null ;
900900 }
901901
902+ // ... (rest of the WorkspaceProvider class)
903+
902904 void onPanDown (DragDownDetails details) {
903905 if (_currentMode == DrawMode .hand) {
904906 return ;
@@ -918,6 +920,41 @@ class WorkspaceProvider extends StateHandler {
918920 }
919921
920922 if (_currentMode == DrawMode .pointer) {
923+ // First, check if a resize handle is being tapped on the currently selected object.
924+ // This check must be performed before the general object hit test.
925+ if (_currentlySelectedObjectId != null ) {
926+ final selectedObject = _canvasObjects[_currentlySelectedObjectId! ];
927+ if (selectedObject != null && selectedObject is ! ConnectorObject ) {
928+ final bounds = selectedObject.getBounds ();
929+
930+ if (Rect .fromCircle (center: bounds.topLeft, radius: _handleHitRadius)
931+ .contains (details.globalPosition)) {
932+ _interactionMode = InteractionMode .resizingTopLeft;
933+ notifyListeners ();
934+ return ;
935+ }
936+ if (Rect .fromCircle (center: bounds.topRight, radius: _handleHitRadius)
937+ .contains (details.globalPosition)) {
938+ _interactionMode = InteractionMode .resizingTopRight;
939+ notifyListeners ();
940+ return ;
941+ }
942+ if (Rect .fromCircle (center: bounds.bottomLeft, radius: _handleHitRadius)
943+ .contains (details.globalPosition)) {
944+ _interactionMode = InteractionMode .resizingBottomLeft;
945+ notifyListeners ();
946+ return ;
947+ }
948+ if (Rect .fromCircle (center: bounds.bottomRight, radius: _handleHitRadius)
949+ .contains (details.globalPosition)) {
950+ _interactionMode = InteractionMode .resizingBottomRight;
951+ notifyListeners ();
952+ return ;
953+ }
954+ }
955+ }
956+
957+ // Next, check for a connection point tap.
921958 final connectionTarget = _findConnectionTarget (details.globalPosition);
922959 if (connectionTarget != null ) {
923960 _interactionMode = InteractionMode .drawingConnector;
@@ -928,17 +965,17 @@ class WorkspaceProvider extends StateHandler {
928965 return ;
929966 }
930967
968+ // Finally, check for a general object tap.
931969 CanvasObject ? tappedObject;
932970 for (final canvasObject in _canvasObjects.values.toList ().reversed) {
933- // Handle hit test for Connectors first since their hit area is a line
934971 if (canvasObject is ConnectorObject ) {
935972 final source = _canvasObjects[canvasObject.sourceId];
936973 final target = _canvasObjects[canvasObject.targetId];
937974 if (source != null && target != null ) {
938975 final startPoint = source.getConnectionPoint (canvasObject.sourceAlignment);
939976 final endPoint = target.getConnectionPoint (canvasObject.targetAlignment);
940977 final distance = _pointToLineDistance (details.globalPosition, startPoint, endPoint);
941- if (distance < 10 ) { // Tolerance for tapping a line
978+ if (distance < 10 ) {
942979 tappedObject = canvasObject;
943980 break ;
944981 }
@@ -950,36 +987,19 @@ class WorkspaceProvider extends StateHandler {
950987 }
951988
952989 if (tappedObject != null ) {
953- if (tappedObject.id != _currentlySelectedObjectId) {
954- changeCurrentlySelectedObj (tappedObject.id);
955- }
956-
990+ changeCurrentlySelectedObj (tappedObject.id);
957991 if (tappedObject is ! ConnectorObject ) {
958- final selectedObject = tappedObject;
959- final bounds = selectedObject.getBounds ();
960-
961- // MODIFIED: Use _handleHitRadius for a larger tap area
962- if (Rect .fromCircle (center: bounds.topLeft, radius: _handleHitRadius).contains (details.globalPosition)) {
963- _interactionMode = InteractionMode .resizingTopLeft;
964- } else if (Rect .fromCircle (center: bounds.topRight, radius: _handleHitRadius).contains (details.globalPosition)) {
965- _interactionMode = InteractionMode .resizingTopRight;
966- } else if (Rect .fromCircle (center: bounds.bottomLeft, radius: _handleHitRadius).contains (details.globalPosition)) {
967- _interactionMode = InteractionMode .resizingBottomLeft;
968- } else if (Rect .fromCircle (center: bounds.bottomRight, radius: _handleHitRadius).contains (details.globalPosition)) {
969- _interactionMode = InteractionMode .resizingBottomRight;
970- } else {
971- final now = DateTime .now ();
972- final isDoubleTap = _lastTappedObjectId == tappedObject.id && _lastTapTime != null && now.difference (_lastTapTime! ) < const Duration (milliseconds: 300 );
992+ final now = DateTime .now ();
993+ final isDoubleTap = _lastTappedObjectId == tappedObject.id && _lastTapTime != null && now.difference (_lastTapTime! ) < const Duration (milliseconds: 300 );
973994
974- _lastTapTime = now;
975- _lastTappedObjectId = tappedObject.id;
995+ _lastTapTime = now;
996+ _lastTappedObjectId = tappedObject.id;
976997
977- if (isDoubleTap) {
978- _interactionMode = InteractionMode .editingText;
979- _lastTappedObjectId = null ;
980- } else {
981- _interactionMode = InteractionMode .moving;
982- }
998+ if (isDoubleTap) {
999+ _interactionMode = InteractionMode .editingText;
1000+ _lastTappedObjectId = null ;
1001+ } else {
1002+ _interactionMode = InteractionMode .moving;
9831003 }
9841004 }
9851005 } else {
0 commit comments