Skip to content

Commit

Permalink
remove ToPopupWindowManager>>autoClosePickOutsideEventClass
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Nov 3, 2024
1 parent a491110 commit ca31fcd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 154 deletions.
132 changes: 5 additions & 127 deletions src/Toplo-Tests/ToPopupWindowManagerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass [
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: windowManager defaultAutoClosePickOutsideEventClass.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
Expand Down Expand Up @@ -60,9 +58,6 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass2 [
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
windowManager autoClosePickOutsideEventClass: BlMouseDownOutsideEvent.
self deny: windowManager autoClosePickOutsideEventClass identicalTo: windowManager defaultAutoClosePickOutsideEventClass.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
Expand All @@ -72,7 +67,7 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass2 [
windowManager currentWindow addEventHandler: (BlEventHandler
on: ToWindowClosedEvent
do: [ :anEvent | closed := true ]).
event := BlMouseDownEvent primary position: 0 @ 0.
event := BlMouseUpEvent primary position: 0 @ 0.
e dispatchEvent: event asMouseOutsideEvent.

" window is closed on mouse-up-outside"
Expand All @@ -90,9 +85,6 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass3 [
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
windowManager autoClosePickOutsideEventClass: BlMouseDownOutsideEvent.
self deny: windowManager autoClosePickOutsideEventClass identicalTo: windowManager defaultAutoClosePickOutsideEventClass.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
Expand All @@ -102,12 +94,12 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass3 [
windowManager currentWindow addEventHandler: (BlEventHandler
on: ToWindowClosedEvent
do: [ :anEvent | closed := true ]).
event := BlMouseUpEvent primary position: 0 @ 0.
event := BlMouseUpEvent primary position: 150 @ 150.
e dispatchEvent: event asMouseOutsideEvent.

" window is not closed on mouse-up-outside"
self deny: windowManager currentWindow isNil.
self deny: closed
" window is closed on mouse-up-outside"
self assert: windowManager currentWindow isNil.
self assert: closed
]

{ #category : #tests }
Expand All @@ -120,9 +112,6 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass4 [
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
windowManager autoClosePickOutsideEventClass: BlMouseUpOutsideEvent.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: windowManager defaultAutoClosePickOutsideEventClass.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
Expand All @@ -140,17 +129,6 @@ ToPopupWindowManagerTest >> testAutoClosePickOutsideEventClass4 [
self deny: closed
]

{ #category : #tests }
ToPopupWindowManagerTest >> testDefaultAutoClosePickOutsideEventClass [

| windowManager |
windowManager := ToPopupWindowManager new.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: windowManager defaultAutoClosePickOutsideEventClass.
windowManager autoClosePickOutsideEventClass: BlMouseDownOutsideEvent.
self deny: windowManager autoClosePickOutsideEventClass identicalTo: windowManager defaultAutoClosePickOutsideEventClass.

]

{ #category : #tests }
ToPopupWindowManagerTest >> testElementEventHandlerClass [

Expand Down Expand Up @@ -229,72 +207,6 @@ ToPopupWindowManagerTest >> testMouseDownInElementEvent [
self assert: windowManager currentWindow isOpened
]

{ #category : #tests }
ToPopupWindowManagerTest >> testMouseDownOutsideEvent [

| e windowManager closed event |
e := ToElement new.
e size: 100 asPoint.
e position: 100 asPoint.
space root addChild: e.
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
windowManager autoClosePickOutsideEventClass: BlMouseDownOutsideEvent.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
self assert: windowManager currentWindow notNil.
self assert: windowManager currentWindow isOpened.
closed := false.
windowManager currentWindow addEventHandler: (BlEventHandler
on: ToWindowClosedEvent
do: [ closed := true ]).
(windowManager autoCloseOnMouseUpDelay + 1 milliSecond) wait.
event := BlMouseDownEvent primary position: 0 @ 0.
e dispatchEvent: event asMouseOutsideEvent.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: BlMouseDownOutsideEvent.
self waitTestingSpaces.

" window is closed on mouse-up "
self assert: windowManager currentWindow isNil.
self assert: closed
]

{ #category : #tests }
ToPopupWindowManagerTest >> testMouseDownOutsideEventWithAutoCloseWithUpOutside [

| e windowManager closed event |
e := ToElement new.
e size: 100 asPoint.
e position: 100 asPoint.
space root addChild: e.
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
windowManager autoClosePickOutsideEventClass: BlMouseUpOutsideEvent.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
self assert: windowManager currentWindow notNil.
self assert: windowManager currentWindow isOpened.
closed := false.
windowManager currentWindow addEventHandler: (BlEventHandler
on: ToWindowClosedEvent
do: [ closed := true ]).
(windowManager autoCloseOnMouseUpDelay + 1 milliSecond) wait.
event := BlMouseDownEvent primary position: 0 @ 0.
e dispatchEvent: event asMouseOutsideEvent.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: BlMouseUpOutsideEvent.
self waitTestingSpaces.

" window is not closed on mouse-down outside here because autoClosePickOutsideEventClass is for mouse-up"
self assert: windowManager currentWindow notNil.
self assert: closed not
]

{ #category : #tests }
ToPopupWindowManagerTest >> testMouseUpEvent [

Expand Down Expand Up @@ -405,47 +317,13 @@ ToPopupWindowManagerTest >> testMouseUpOutsideEvent [
(windowManager autoCloseOnMouseUpDelay + 1 milliSecond) wait.
event := BlMouseUpEvent primary position: 0 @ 0.
e dispatchEvent: event asMouseOutsideEvent.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: BlMouseUpOutsideEvent.
self waitTestingSpaces.

" window is closed on mouse-up "
self assert: windowManager currentWindow isNil.
self assert: closed
]

{ #category : #tests }
ToPopupWindowManagerTest >> testMouseUpOutsideEventWithAutoCloseWithDownOutside [

| e windowManager closed event |
e := ToElement new.
e size: 100 asPoint.
e position: 100 asPoint.
space root addChild: e.
self waitTestingSpaces.

windowManager := ToPopupWindowManager new.
windowManager autoClosePickOutsideEventClass: BlMouseDownOutsideEvent.

e addEventHandler: windowManager.
BlSpace simulateMouseDownOn: e.
self waitTestingSpaces.
self assert: windowManager currentWindow notNil.
self assert: windowManager currentWindow isOpened.
closed := false.
windowManager currentWindow addEventHandler: (BlEventHandler
on: ToWindowClosedEvent
do: [ closed := true ]).
(windowManager autoCloseOnMouseUpDelay + 1 milliSecond) wait.
event := BlMouseUpEvent primary position: 0 @ 0.
e dispatchEvent: event asMouseOutsideEvent.
self assert: windowManager autoClosePickOutsideEventClass identicalTo: BlMouseDownOutsideEvent.
self waitTestingSpaces.

" window is not closed on mouse-up outside here because autoClosePickOutsideEventClass is for mouse-down"
self assert: windowManager currentWindow notNil.
self assert: closed not
]

{ #category : #tests }
ToPopupWindowManagerTest >> testNoAutoCloseEvenAfterLongDelay [

Expand Down
6 changes: 0 additions & 6 deletions src/Toplo-Widget-Select/ToSelectPopupWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ ToSelectPopupWindowManager >> defaultAutoCloseOnMouseUpDelay [
^ nil
]

{ #category : #initialization }
ToSelectPopupWindowManager >> defaultAutoClosePickOutsideEventClass [

^ BlMouseUpOutsideEvent
]

{ #category : #'api - hooks' }
ToSelectPopupWindowManager >> defaultListElementEventHandler [

Expand Down
22 changes: 1 addition & 21 deletions src/Toplo/ToPopupWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Class {
#superclass : #ToAnchoredWindowManager,
#instVars : [
'autoCloseOnMouseUpDelay',
'autoClosePickOutsideEventClass',
'mouseButton',
'popupDelay',
'popupOnMouseEnter',
Expand All @@ -27,18 +26,6 @@ ToPopupWindowManager >> autoCloseOnMouseUpDelay: aDelay [
autoCloseOnMouseUpDelay := aDelay ifNotNil: [:d| d asDuration ]
]

{ #category : #accessing }
ToPopupWindowManager >> autoClosePickOutsideEventClass [

^ autoClosePickOutsideEventClass
]

{ #category : #accessing }
ToPopupWindowManager >> autoClosePickOutsideEventClass: anEventClass [

autoClosePickOutsideEventClass := anEventClass
]

{ #category : #accessing }
ToPopupWindowManager >> closeOnMouseDown [

Expand Down Expand Up @@ -75,12 +62,6 @@ ToPopupWindowManager >> defaultAutoCloseOnMouseUpDelay [
^ 300 milliSeconds
]

{ #category : #initialization }
ToPopupWindowManager >> defaultAutoClosePickOutsideEventClass [

^ BlMouseUpOutsideEvent
]

{ #category : #accessing }
ToPopupWindowManager >> defaultPopupDelay [

Expand Down Expand Up @@ -119,15 +100,14 @@ ToPopupWindowManager >> eventsToHandle [
BlMouseDownEvent.
BlMouseEnterEvent.
BlMouseLeaveEvent.
self autoClosePickOutsideEventClass }
BlMouseUpOutsideEvent }
]

{ #category : #initialization }
ToPopupWindowManager >> initialize [

super initialize.
self usePrimaryMouseButton .
self autoClosePickOutsideEventClass: self defaultAutoClosePickOutsideEventClass.
popupDelay := self defaultPopupDelay.
autoCloseOnMouseUpDelay := self defaultAutoCloseOnMouseUpDelay.
popupOnMouseEnter := false.
Expand Down

0 comments on commit ca31fcd

Please sign in to comment.