Skip to content

Commit

Permalink
Merge pull request #492 from pharo-graphics/AddEventConsume
Browse files Browse the repository at this point in the history
Add BlEvent>>consume that is equivalent to consume: true
  • Loading branch information
tinchodias authored Apr 9, 2024
2 parents 46e98f5 + 4299107 commit 614998a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Bloc-DevTool/BlSelectionTool.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ BlSelectionTool >> dragEvent: anEvent [

{ #category : #'dnd handlers' }
BlSelectionTool >> dragStartEvent: anEvent [
anEvent consumed: true.


anEvent consume.
self resetCurrentSelections.
startPosition := anEvent position.
selectionRect size:50@50; position:startPosition.
Expand Down
5 changes: 3 additions & 2 deletions src/Bloc-PullAndSlide/BlScrollSlideHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ BlScrollSlideHandler >> initialize [

{ #category : #'mouse handlers' }
BlScrollSlideHandler >> mouseWheelEvent: anEvent [

| aTargetElement |
anEvent consumed: true.
anEvent consume.

aTargetElement := targetElement ifNil: anEvent currentTarget.
aTargetElement := targetElement ifNil: [ anEvent currentTarget ].

aTargetElement children accountedByLayout do: [ :aChild |
| aHorizontalScrollDelta aVerticalScrollDelta |
Expand Down
16 changes: 10 additions & 6 deletions src/Bloc-PullAndSlide/BlSlideHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Class {

{ #category : #'dnd handlers' }
BlSlideHandler >> dragEvent: anEvent [

| aStartPosition aCurrentPosition aDelta aTargetElement |
anEvent consumed: true.

aTargetElement := targetElement ifNil: anEvent currentTarget.
anEvent consume.
aTargetElement := targetElement ifNil: [ anEvent currentTarget ].

aStartPosition := aTargetElement globalPointToChildren: dragStartPosition.
aCurrentPosition := aTargetElement globalPointToChildren: anEvent position.
Expand All @@ -33,13 +33,17 @@ BlSlideHandler >> dragEvent: anEvent [

{ #category : #'dnd handlers' }
BlSlideHandler >> dragStartEvent: anEvent [
anEvent consumed: true.

anEvent consume.

"drag start position in space"
dragStartPosition := anEvent position.

(targetElement ifNil: anEvent currentTarget) children accountedByLayout
do: [ :aChild | aChild userData at: #slideHandlerStartPosition put: aChild constraints position ]
(targetElement ifNil: [ anEvent currentTarget ]) children accountedByLayout
do: [ :aChild |
aChild userData
at: #slideHandlerStartPosition
put: aChild constraints position ]
]

{ #category : #accessing }
Expand Down
7 changes: 7 additions & 0 deletions src/Bloc/BlEvent.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ BlEvent >> capturingTarget: aTBlEventTarget [
currentTarget := aTBlEventTarget
]

{ #category : #testing }
BlEvent >> consume [

consumed := true
]

{ #category : #testing }
BlEvent >> consumed: aBoolean [

consumed := aBoolean
]

Expand Down
7 changes: 4 additions & 3 deletions src/Bloc/BlSelectionHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ BlSelectionHandler >> computeSelectionArea [

{ #category : #'dnd handlers' }
BlSelectionHandler >> dragEndEvent: anEvent [
anEvent consumed: true.

anEvent consume.

origin := nil.
corner := nil.
Expand All @@ -41,7 +42,7 @@ BlSelectionHandler >> dragEvent: anEvent [
self hasOrigin
ifFalse: [ ^ self ].

anEvent consumed: true.
anEvent consume.

corner := anEvent position.
self computeSelectionArea.
Expand All @@ -51,8 +52,8 @@ BlSelectionHandler >> dragEvent: anEvent [

{ #category : #'dnd handlers' }
BlSelectionHandler >> dragStartEvent: anEvent [
anEvent consumed: true.

anEvent consume.
origin := anEvent position
]

Expand Down
2 changes: 1 addition & 1 deletion src/Bloc/BlShortcutHandlerWithShortcuts.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ BlShortcutHandlerWithShortcuts >> handleEvent: aShortcutEvent [
| aShortcut |
aShortcut := theShortcuts first key.
"let users explicitely set consumed to false so it bubbles up"
aShortcutEvent consumed: true.
aShortcutEvent consume.
aShortcut performDueTo: aShortcutEvent ]
]

Expand Down

0 comments on commit 614998a

Please sign in to comment.