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

Fix doubleClick on tab and on text selection. #13906

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/Morphic-Base/MouseClickState.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,9 @@ MouseClickState >> handleEvent: evt from: aHand [
^true].
localEvt isMouseDown ifTrue:["double click"
clickState := #secondClickDown.
"We should not double click if not on the same element"
(clickClient containsPoint: localEvt position) ifTrue: [
self doubleClick.
^false] ] ].
self doubleClick.
^false]
].

clickState == #secondClickDown ifTrue: [
isDragSecond ifTrue: ["drag start"
Expand Down
3 changes: 2 additions & 1 deletion src/Morphic-Core/Morph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2235,7 +2235,8 @@ Morph >> doesOwnRotation [
{ #category : #'event handling' }
Morph >> doubleClick: evt [
"Handle a double-click event. This message is only sent to clients that request it by sending #waitForClicksOrDrag:event: to the initiating hand in their mouseDown: method. This default implementation does nothing."

"We should not double click if not on the same element"
(self containsPoint: evt position) ifFalse: [ ^self ].
^ self eventHandler ifNotNil:
[self eventHandler doubleClick: evt fromMorph: self]
]
Expand Down
2 changes: 2 additions & 0 deletions src/Morphic-Tests/MockMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ MockMorph >> myMagicClick: event [

{ #category : #events }
MockMorph >> myMagicDoubleClick: event [
"Each client should check if it contains the point"
(self containsPoint: event position) ifFalse: [ ^self ].
magicDoubleClick := event
]
11 changes: 9 additions & 2 deletions src/Morphic-Tests/MorphicEventHandlerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ MorphicEventHandlerTest >> testClickFromMorph [

{ #category : #tests }
MorphicEventHandlerTest >> testDoubleClickFromMorph [
| event |
event := MouseButtonEvent new
setType: #mouseDown
position: 0@0
which: 0
buttons: 4
hand: morph eventHandler
stamp: Time millisecondClockValue.
morph eventHandler on: #doubleClick send: #value to: true.

self assert: (morph doubleClick: nil) identicalTo: true
self assert: (morph doubleClick: event) identicalTo: true
]

{ #category : #tests }
Expand Down
16 changes: 16 additions & 0 deletions src/Rubric-Tests/RubEditingAreaTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,19 @@ RubEditingAreaTest >> testMouseMoveAfterDoubleClick [
self assert: area markBlock stringIndex equals: 9.
self assert: area pointBlock stringIndex equals: 17
]

{ #category : #'tests - accessing selection' }
RubEditingAreaTest >> testSelectAllWithDoubleClickAfterLastLine [
| text index buttons |
text := 'one
two
three
four'.
area setTextWith: text.
index := text size + 20. "an index out of bounds of string"
buttons := MouseButtonEvent redButton.
position := 20@100.
area simulateClickWith: buttons position: position.
self sendDoubleClickAt: index withShift: false.
self assert: area selection equals: text.
]