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

Can't listen mouse right click #151

Open
tinchodias opened this issue Jun 1, 2021 · 8 comments
Open

Can't listen mouse right click #151

tinchodias opened this issue Jun 1, 2021 · 8 comments

Comments

@tinchodias
Copy link
Collaborator

Check with this snippet:

anElement := BlElement new
	size: 100 asPoint;
	relocate: 50 asPoint;
	background: Color blue;
	when: BlClickEvent do: [ :anEvent | self inform: anEvent button asString ];
	yourself.
	
aSpace := BlSpace new
	addChild: anElement;
	show;
	yourself.
@tinchodias
Copy link
Collaborator Author

tinchodias commented Jun 1, 2021

This would be fixed if BlMouseProcessor>>#canBeClickEvent:, which is defined as:

canBeClickEvent: aMouseUpEvent
	^ dndInProgress not
		and: [ (previousMouseDownEvent isNotNil and: [ previousMouseDownEvent primaryButtonPressed ])
				and: [ aMouseUpEvent target = previousMouseDownEvent target ] ]

We could use anyButtonPressed instead of only primary* to consider any button. But in fact, since this is a mouse up... just not check like in:

canBeClickEvent: aMouseUpEvent

	^ dndInProgress not and: [ 
		  previousMouseDownEvent isNotNil and: [ 
			  aMouseUpEvent target = previousMouseDownEvent target ] ]

May have a negative impact in brick widgets, such as checkbox, that will start to respond to right click.

@tinchodias
Copy link
Collaborator Author

I see the class comment BlMouseClick now:

The click event is fired when a pointing device button (a mouse's primary button) is pressed and released on a single element.

The order of fired events:

 - Mouse Down
 - Mouse Up
 - Click

May be a more adequate solution than #152 to create a BlRightClick class.

@tinchodias
Copy link
Collaborator Author

tinchodias commented Jun 1, 2021

Also, it may me convenient (to ease use) to transform BlMouseClick into a hierarchy of

BlMouseClick
   BlPrimaryMouseClick
   BlMiddleMouseClick
   BlSecondaryMouseClick

the names would be consistent with the hierarchy of buttons in BlMouseNamedButton:

Screen Shot 2021-06-01 at 15 58 59

(there is also "other button"...)

@tinchodias
Copy link
Collaborator Author

@plantec did you have this issue with right-click in Toplo? I wonder if there is another way to listen right-click that I didn't see.

@plantec
Copy link
Collaborator

plantec commented Jun 22, 2023

Hello Martin,
click and other mouse event management within widgets is a nightmare :)
editor, list and buttons have different rules and I think Toplo should be reworked regarding this.

@plantec
Copy link
Collaborator

plantec commented Jun 22, 2023

Regarding context menu, two scenarios:
1 - popup on mouse-down and action launched on mouse-up on an item (or menu closed if up outside)
2 - popup on click, then the context menu stays opened until a click outside or a click on an item.
currently, toplo implements the second one but should also implement the first one

@tinchodias
Copy link
Collaborator Author

I added it in Toplo to remember it

@plantec
Copy link
Collaborator

plantec commented Jun 28, 2023

I've removed button check from canBeClickEvent: according to your comment. Now, the button can be tested when receiving a click event

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

2 participants