pharo-graphics / Bloc

Low-level UI infrastructure & framework for Pharo
MIT License
83 stars 40 forks source link

Click event instead of drag-like event #598

Open labordep opened 2 months ago

labordep commented 2 months ago

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:

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 commented 2 months ago

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 commented 2 months ago

It seems to be on Pharo 12

rvillemeur commented 6 days ago

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: