Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When drag is started, BlDragEvents replace BlMouseMoves #649

Open
tinchodias opened this issue Nov 19, 2024 · 5 comments
Open

When drag is started, BlDragEvents replace BlMouseMoves #649

tinchodias opened this issue Nov 19, 2024 · 5 comments

Comments

@tinchodias
Copy link
Collaborator

Snippet:

events := OrderedCollection new.
e := BlElement new
	background: Color blue;
	position: 50@50;
	size: 400@50;
	addEventHandlerOn: BlEvent do: [ :evt | events add: evt ];
	addEventHandlerOn: BlDragStartEvent do: [ :evt | evt consume ];
	yourself.

s := e openInSpace.
s extent: 500 @ 200.

This is intentionally implemented in BlMouseProcessor>>#handleMouseMove:. But shouldn't BlMouseMove continue being delivered, at the same time as the BlDragEvent?

(@labordep @ELePors @tesonep)
@Enzo-Demeulenaere what do you think?

@tinchodias tinchodias changed the title When drag started BlDragEvents replace BlMouseMoves When drag is started, BlDragEvents replace BlMouseMoves Nov 19, 2024
@Enzo-Demeulenaere
Copy link
Contributor

I didn't know this was the case.

On one hand I think it is important to make the difference between moves and drag but on the other I totally agree that something listening to mouse moves should still be able to know the mouse is moving but then how could we make the difference.

I'm curious to know the discussion on this as it was first implemented

@labordep
Copy link
Contributor

I confirm this behavior on Windows.

@labordep
Copy link
Contributor

labordep commented Nov 19, 2024

Without addEventHandlerOn: BlDragStartEvent do: [ :evt | evt consume ]; I receive continuous mouse move and mose drag start too. That's strange and we should receive only one start drag event, and after during the move a lot drag event + all mouse move events, I think.

@tinchodias
Copy link
Collaborator Author

tinchodias commented Nov 19, 2024

Only when an event handler marks a BlDragStartEvent as "consumed", the mouse processor knows that a drag really started. In other words, each BlDragStartEvent that is dispatched is an opportunity for a handler to really start the drag and drop.

As I understand it, using "consumed" flag for this purpose can be misleading for the humans that read the code :)
Probably the idea was to save memory (i.e. avoid adding a new specific instvar such as reallyStartDrag or so).

Even more, maybe BlDragStartEvent could be renamed so it communicates better to humans that it is a potential drag. Something like BlDragStartRequestEvent? BlDragPotentialStartEvent?

@labordep
Copy link
Contributor

labordep commented Nov 20, 2024

Hi @tinchodias, thanks for your analyse.
I think "BlDragStartEvent" is good, in fact this is true. But it should be send just one time.
This is not the same type of a "mouse move" event: it should be send just one time at the beginning of the drag.
After that a "DragEvent" is send in addition to each "mouse move" (to have the capacity to process these two types of events independently).
At the end of a drag (mouse button release or something else that cancel the drag) a "DragStopEvent" is sended.
Eventually a "DropEvent" when not canceled, but maybe this is already the case ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants