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 1 commit
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
]
26 changes: 26 additions & 0 deletions src/Rubric-Tests/RubEditingAreaTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,29 @@ 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'.
"r character from word 'three'"
"index := text indexOf: $r.
self sendMouseClickAt: index withShift: false.
self sendDoubleClickAt: index withShift: false.
self assert: area selection equals: 'three'."
area setTextWith: text.
index := text size + 20. "an index out of bounds of string"
buttons := MouseButtonEvent redButton.
position := 20@100.
(area paragraph characterBlockForIndex: text size) surface leftCenter traceCr.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pay attention the traceCr should be removed.

area simulateClickWith: buttons position: position.
self sendDoubleClickAt: index withShift: false.
self assert: area selection equals: text.




]