# HG changeset patch
# User Jan Vrany <jan.vrany@fit.cvut.cz>
# Date 1521413527 0
# Sun Mar 18 22:52:07 2018 +0000
# Node ID b6dbdc4fd7f53acdca286b9f5e18c98563b3f41c
# Parent 031924a79f90e2289fe3e75823ad7bc8466d8e5a
Issue #176: fix "disappearing" completon view when pointer moves out of it
...by making it a popup view (which it is, of sorts) and opening it modally.
While this changes the behavior a little, should behave better on windows
with "focus-follows-mouse".
diff -r 031924a79f90 -r b6dbdc4fd7f5 SmallSense__CompletionController.st
a
|
b
|
|
498 | 498 | movePos y: (movePos y - windowExtent y - editView font maxHeight - 5). |
499 | 499 | ]. |
500 | 500 | topView origin:movePos. |
| 501 | topView |
| 502 | bePopUpView; |
| 503 | beSlave. |
501 | 504 | "/ topView resizeToFit. |
502 | 505 | self updateSelection ifFalse:[ |
503 | | topView open. |
| 506 | topView openModal. |
504 | 507 | ]. |
505 | 508 | ] ifFalse:[ |
506 | 509 | completionView list:list. |
… |
… |
|
514 | 517 | |
515 | 518 | "Created: / 27-09-2013 / 14:01:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
516 | 519 | "Modified: / 15-05-2014 / 11:30:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
| 520 | "Modified (format): / 15-03-2018 / 10:47:27 / jv" |
517 | 521 | ! |
518 | 522 | |
519 | 523 | updateCompletions: completionResult sequence: sequence |
diff -r 031924a79f90 -r b6dbdc4fd7f5 SmallSense__CompletionView.st
a
|
b
|
|
20 | 20 | |
21 | 21 | "{ NameSpace: SmallSense }" |
22 | 22 | |
23 | | SimpleView subclass:#CompletionView |
| 23 | TopView subclass:#CompletionView |
24 | 24 | instanceVariableNames:'completionController completionContext list listHolder listView |
25 | 25 | selectionHolder helpHolder helpView' |
26 | 26 | classVariableNames:'' |
… |
… |
|
125 | 125 | !CompletionView methodsFor:'event handling'! |
126 | 126 | |
127 | 127 | keyPress:key x:x y:y |
128 | | x isNil ifTrue:[ |
129 | | "/ Already re-delegated |
130 | | ^ self |
131 | | ]. |
132 | 128 | key == #Escape ifTrue:[ |
133 | 129 | completionController closeCompletionView. |
134 | 130 | ^ self |
135 | | ]. |
| 131 | ]. |
136 | 132 | (key == #CursorDown |
137 | 133 | or:[ key == #CursorUp |
138 | | or:[ key == #CursorLeft |
139 | | or:[ key == #CursorRight |
140 | | or:[ ((key == #Return) and:[ self hasSelection ])]]]]) ifTrue:[ |
| 134 | or:[ ((key == #Return) and:[ self hasSelection ])]]) ifTrue:[ |
141 | 135 | listView keyPress:key x:x y:y. |
142 | 136 | ^ self |
143 | 137 | ]. |
… |
… |
|
145 | 139 | ^ completionController editView keyPress:key x:x y:y |
146 | 140 | |
147 | 141 | "Created: / 27-09-2013 / 14:05:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
148 | | "Modified: / 31-03-2014 / 22:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
149 | 142 | "Modified: / 18-01-2018 / 23:10:58 / jv" |
| 143 | "Modified (comment): / 17-04-2018 / 15:14:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
| 144 | ! |
| 145 | |
| 146 | keyPress:key x:x y:y view: view |
| 147 | view == listView ifTrue:[ |
| 148 | (key == #CursorDown |
| 149 | or:[ key == #CursorUp |
| 150 | or:[ key == #Return]]) ifTrue:[ |
| 151 | ^ false |
| 152 | ] ifFalse:[ |
| 153 | completionController editView keyPress:key x:x y:y. |
| 154 | ^ true |
| 155 | ]. |
| 156 | ]. |
| 157 | ^ false |
| 158 | |
| 159 | "Created: / 17-04-2018 / 09:54:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
| 160 | "Modified (comment): / 17-04-2018 / 15:13:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
150 | 161 | ! ! |
151 | 162 | |
152 | 163 | !CompletionView methodsFor:'initialization & release'! |
… |
… |
|
168 | 179 | listView := listViewScroller scrolledView. |
169 | 180 | listView listHolder: listHolder. |
170 | 181 | listView model: selectionHolder. |
| 182 | listView delegate: self. |
171 | 183 | listView highlightMode: #line. |
172 | 184 | listView doubleClickAction:[:index | self complete: index ]. |
173 | 185 | |
… |
… |
|
182 | 194 | self extent: 400 @ 250 |
183 | 195 | |
184 | 196 | "Created: / 27-09-2013 / 13:56:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
185 | | "Modified: / 04-04-2014 / 15:03:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
| 197 | "Modified: / 17-04-2018 / 09:53:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
186 | 198 | ! ! |
187 | 199 | |
188 | 200 | !CompletionView methodsFor:'queries'! |
189 | 201 | |
| 202 | handlesKeyPress: key inView: view |
| 203 | ^ view == listView and:[ key isCharacter ] |
| 204 | |
| 205 | "Created: / 17-04-2018 / 09:55:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
| 206 | ! |
| 207 | |
190 | 208 | hasSelection |
191 | 209 | ^listView hasSelection |
192 | 210 | |