Skip to content

Commit

Permalink
Merge pull request pharo-project#14287 from pharo-project/14149-Check…
Browse files Browse the repository at this point in the history
…-backport-Pharo11-Fix-doubleClick-on-tab-and-on-text-selection-13906

 backport Pharo11: Fix doubleClick on tab and on text selection.
  • Loading branch information
jecisc committed Jul 14, 2023
2 parents 7ba1b4e + 0add626 commit e3f3049
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/Morphic-Base/MouseClickState.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,12 @@ MouseClickState >> handleEvent: evt from: aHand [
"timed out after mouseUp - signal timeout and pass the event"
aHand resetClickState.
self doubleClickTimeout. "***"
^true].
^ 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
14 changes: 7 additions & 7 deletions src/Morphic-Base/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ Object class >> taskbarIcon [
]

{ #category : #'*Morphic-Base' }
Object >> taskbarIconName [
"Answer the icon for the receiver in a task bar
or nil for the default."
Object class >> taskbarIconName [
"Answer the icon for an instance of the receiver in a task bar"

^self class taskbarIconName
^#smallWindow
]

{ #category : #'*Morphic-Base' }
Object class >> taskbarIconName [
"Answer the icon for an instance of the receiver in a task bar"
Object >> taskbarIconName [
"Answer the icon for the receiver in a task bar
or nil for the default."

^#smallWindow
^self class taskbarIconName
]

{ #category : #'*Morphic-Base' }
Expand Down
2 changes: 2 additions & 0 deletions src/Morphic-Core/Morph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2236,6 +2236,8 @@ Morph >> doesOwnRotation [
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: 10 additions & 1 deletion src/Morphic-Tests/MorphicEventHandlerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ 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 }
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.
]

0 comments on commit e3f3049

Please sign in to comment.