Bloc icon indicating copy to clipboard operation
Bloc copied to clipboard

Click event instead of drag-like event

Open labordep opened this issue 1 year ago • 2 comments

Hi @tinchodias,

I detect a problem, for me. But we need to discuss and get a solution.

I'm using a BlEventListener subclass to write behavior on a click. Here my example:

BlEventListener << #MyEventListener
>>clickEvent: anEvent

So, I want to do something on mouse click. The problem is that I receive a click after than my mouse is moving!

To reproduce:

  • place a breakpoint in the beginning of clickEvent:
  • press the mouse button (left button for a Windows/Linux mouse)
  • move the mouse inside the blspace, in example a distance of 300px
  • release the mouse button : breakpoint open

I think this is not normal to get a click if the mouse distance between the press and the release is more than, in example, 5px (to absorb body precision - vibration etc.). Because if the distance is large this is more similar to a drag event.

My concrete problem is: I want to select an object by click. Imagine a cartographic view with object as cities on it. I click on a city to select it without move the mouse : ok. But when I press the mouse button on the city position, and after I move inside another city and I release the button, I got a click and the city far my cursor is selected!

labordep avatar Sep 06 '24 07:09 labordep

You can reproduce it in a Toplo example:

In the menu Toplo>Examples>Source code browser

https://github.com/user-attachments/assets/1aa3d434-ea07-4d8a-9cc9-87cbf83be3b3

Click on a element, drag, release: the element is selected but far from mouse! It should be a drag-finish or a click aborted event.

labordep avatar Sep 06 '24 07:09 labordep

It seems to be on Pharo 12

labordep avatar Sep 06 '24 08:09 labordep

Not sure if it helps, but here is the current sequence of action & event for Clic and Drag, with default listener, BlSpaceEventListener

BlMouseMoveEvent
    -> BlSpaceEventListener >> mouseMoveEvent: 
        -> BlMouseProcessor >> handleMouseMove: anEvent
            -> BlMouseProcessor >> processPicking: anEvent
            -> BlMouseProcessor >> processDragMove: aMouseMoveEvent
                -> BlMouseProcessor >> fireAsDragEvent: anEvent
                    BlDragEvent                    
                        -> BlDropHandler >>dragEvent:aDragEvent                    
                            BlSpaceDragDraggedEvent 
                                -> BlSpaceEventListener >> spaceDragDraggedEvent: anEvent
                -> BlMouseProcessor >> subprocessDragEnterExitEvent: aMouseEvent
                    -> BlMouseProcessor >> fireAsDragLeaveEvent: aMouseEvent targets: newExitedTargets.
                    -> BlMouseProcessor >> fireAsDragEnterEvent: anEvent targets: aCollection
                        BlDragEnterEvent
                            BlDropHandler >> dragEnterEvent: aDropEnterEvent
                                BlSpaceDragDropEnterEvent 
                                    -> BlSpaceEventListener >> spaceDragDropEnterEvent: anEvent
            -> BlMouseProcessor >> tryDragStart: aMouseEvent
                -> BlMouseEvent >> asDragStartEvent
                    BlDragStartEvent 
                        -> BlDragHandler >> dragStartEvent: anEvent
                            -> BlSpaceDragLiftEvent 
                                -> BlSpaceEventListener >> spaceDragLiftEvent:

rvillemeur avatar Nov 02 '24 22:11 rvillemeur

I close this issue after we talked with @labordep today and see it's fixed.

tinchodias avatar Nov 19 '24 19:11 tinchodias