1278 modalTops modalTop modalDelegate syntheticEvent keyboardProcessor |
1278 modalTops modalTop modalDelegate syntheticEvent keyboardProcessor |
1279 busyHookBlock busyHookCalled| |
1279 busyHookBlock busyHookCalled| |
1280 |
1280 |
1281 self processExposeEvents. |
1281 self processExposeEvents. |
1282 |
1282 |
1283 LastEventQuerySignal handle:[:ex | |
1283 [ |
1284 ex proceedWith:event |
1284 LastEventQuerySignal handle:[:ex | |
1285 ] do:[ |
1285 ex proceedWith:event |
1286 [mySensor notNil |
1286 ] do:[ |
1287 and:[(event := mySensor nextEvent) notNil]] whileTrue:[ |
1287 [mySensor notNil |
1288 ignore := false. |
1288 and:[(event := mySensor nextEvent) notNil]] whileTrue:[ |
1289 focus := focusView. |
1289 ignore := false. |
1290 modalDelegate := false. |
1290 focus := focusView. |
1291 modalTop := nil. |
1291 modalDelegate := false. |
1292 |
1292 modalTop := nil. |
1293 modalGroup notNil ifTrue:[ |
1293 |
1294 "/ an incoming event for a masterView, |
1294 modalGroup notNil ifTrue:[ |
1295 "/ while being blocked by some other modalView. |
1295 "/ an incoming event for a masterView, |
1296 |
1296 "/ while being blocked by some other modalView. |
1297 modalTops := modalGroup topViews. |
1297 |
1298 modalTops size > 0 ifTrue:[ |
1298 modalTops := modalGroup topViews. |
1299 modalTop := modalTops first. |
1299 modalTops size > 0 ifTrue:[ |
1300 ]. |
1300 modalTop := modalTops first. |
1301 |
|
1302 event isKeyEvent ifTrue:[ |
|
1303 "/ forward keyboard events to my modal |
|
1304 "/ groups first topView ... |
|
1305 modalTop notNil ifTrue:[ |
|
1306 focus := modalTop. |
|
1307 modalDelegate := true. |
|
1308 ]. |
1301 ]. |
1309 modalGroup focusView notNil ifTrue:[ |
1302 |
1310 focus := modalGroup focusView |
1303 event isKeyEvent ifTrue:[ |
1311 ] |
1304 "/ forward keyboard events to my modal |
1312 ] ifFalse:[ |
1305 "/ groups first topView ... |
1313 event isFocusEvent ifTrue:[ |
1306 modalTop notNil ifTrue:[ |
1314 event isFocusInEvent ifTrue:[ |
1307 focus := modalTop. |
1315 "/ move focus over to modalBox |
1308 modalDelegate := true. |
1316 modalTop notNil ifTrue:[ |
1309 ]. |
1317 modalTop getKeyboardFocus. |
1310 modalGroup focusView notNil ifTrue:[ |
1318 "/ focusIn is forwarded to the modalGroup |
1311 focus := modalGroup focusView |
1319 "/ (since keyboard is forwarded) |
1312 ] |
1320 event view:modalTop. |
1313 ] ifFalse:[ |
1321 focus := modalTop. |
1314 event isFocusEvent ifTrue:[ |
1322 ] |
1315 event isFocusInEvent ifTrue:[ |
|
1316 "/ move focus over to modalBox |
|
1317 modalTop notNil ifTrue:[ |
|
1318 modalTop getKeyboardFocus. |
|
1319 "/ focusIn is forwarded to the modalGroup |
|
1320 "/ (since keyboard is forwarded) |
|
1321 event view:modalTop. |
|
1322 focus := modalTop. |
|
1323 ] |
|
1324 ] ifFalse:[ |
|
1325 "/ focusOut goes to both the modal and |
|
1326 "/ the blocked main-group |
|
1327 "/ (actually, only the very first focusOut |
|
1328 "/ is needed in the mainGroup (to turn off the cursor) |
|
1329 "/ all others are only needed in the modalGroup) |
|
1330 |
|
1331 "/ syntheticEvent := event copy. |
|
1332 "/ syntheticEvent view:modalTop. |
|
1333 "/ LastEventQuerySignal handle:[:ex | |
|
1334 "/ ex proceedWith:syntheticEvent |
|
1335 "/ ] do:[ |
|
1336 "/ syntheticEvent sendEventWithFocusOn:nil. |
|
1337 "/ ]. |
|
1338 |
|
1339 "/ event view:modalTop. |
|
1340 ]. |
|
1341 modalDelegate := true. |
1323 ] ifFalse:[ |
1342 ] ifFalse:[ |
1324 "/ focusOut goes to both the modal and |
1343 event isPointerLeaveEvent ifTrue:[ |
1325 "/ the blocked main-group |
1344 ] ifFalse:[ |
1326 "/ (actually, only the very first focusOut |
1345 event isUserEvent ifTrue:[ |
1327 "/ is needed in the mainGroup (to turn off the cursor) |
1346 ignore := true |
1328 "/ all others are only needed in the modalGroup) |
1347 ] |
1329 |
|
1330 "/ syntheticEvent := event copy. |
|
1331 "/ syntheticEvent view:modalTop. |
|
1332 "/ LastEventQuerySignal handle:[:ex | |
|
1333 "/ ex proceedWith:syntheticEvent |
|
1334 "/ ] do:[ |
|
1335 "/ syntheticEvent sendEventWithFocusOn:nil. |
|
1336 "/ ]. |
|
1337 |
|
1338 "/ event view:modalTop. |
|
1339 ]. |
|
1340 modalDelegate := true. |
|
1341 ] ifFalse:[ |
|
1342 event isPointerLeaveEvent ifTrue:[ |
|
1343 ] ifFalse:[ |
|
1344 event isUserEvent ifTrue:[ |
|
1345 ignore := true |
|
1346 ] |
1348 ] |
1347 ] |
1349 ] |
1348 ] |
1350 ] |
1349 ] |
1351 ]. |
1350 ]. |
1352 |
1351 |
1353 ignore ifFalse:[ |
1352 ignore ifFalse:[ |
1354 (views notNil or:[topViews notNil]) ifTrue:[ |
1353 (views notNil or:[topViews notNil]) ifTrue:[ |
1355 |
1354 |
1356 "/ give eventRecorders, catchers etc. |
1355 "/ give eventRecorders, catchers etc. |
1357 "/ a chance to eat or modify that event |
1356 "/ a chance to eat or modify that event |
1358 |
1357 |
1359 (preEventHook notNil |
1358 (preEventHook notNil |
1360 and:[preEventHook processEvent:event]) ifTrue:[ |
1359 and:[preEventHook processEvent:event]) ifTrue:[ |
1361 ignore := true. |
1360 ignore := true. |
|
1361 ]. |
|
1362 |
|
1363 ignore ifFalse:[ |
|
1364 evView := event view. |
|
1365 |
|
1366 (event isKeyEvent |
|
1367 and:[(keyboardProcessor := (modalTop ? evView topView) keyboardProcessor) notNil]) ifTrue:[ |
|
1368 ignore := keyboardProcessor processEvent:event forModalView:modalTop |
|
1369 ]. |
1362 ]. |
1370 ]. |
1363 |
1371 |
1364 ignore ifFalse:[ |
1372 ignore ifFalse:[ |
1365 evView := event view. |
1373 "/ event handling below will vanish ... |
1366 |
1374 "/ (keyboardProcessor will do it) |
1367 (event isKeyEvent |
1375 |
1368 and:[(keyboardProcessor := (modalTop ? evView topView) keyboardProcessor) notNil]) ifTrue:[ |
1376 event isKeyPressEvent ifTrue:[ |
1369 ignore := keyboardProcessor processEvent:event forModalView:modalTop |
1377 event key == #Escape ifTrue:[ |
1370 ]. |
1378 modalDelegate ifTrue:[ |
1371 ]. |
1379 modalTop hideRequest |
1372 |
1380 ] ifFalse:[ |
1373 ignore ifFalse:[ |
1381 isModal ifTrue:[ |
1374 "/ event handling below will vanish ... |
1382 topViews size > 0 ifTrue:[ |
1375 "/ (keyboardProcessor will do it) |
1383 topViews first hideRequest |
1376 |
|
1377 event isKeyPressEvent ifTrue:[ |
|
1378 event key == #Escape ifTrue:[ |
|
1379 modalDelegate ifTrue:[ |
|
1380 modalTop hideRequest |
|
1381 ] ifFalse:[ |
|
1382 isModal ifTrue:[ |
|
1383 topViews size > 0 ifTrue:[ |
|
1384 topViews first hideRequest |
|
1385 ] |
1384 ] |
1386 ] |
1385 ] |
1387 ] |
1386 ] |
1388 ] |
1387 ] |
1389 ] ifFalse:[ |
1388 ] ifFalse:[ |
1390 "/ |
|
1391 "/ keep track of which view has the pointer |
|
1392 "/ |
|
1393 event isPointerEnterEvent ifTrue:[ |
|
1394 pointerView := evView |
|
1395 ] ifFalse:[ |
|
1396 event isPointerLeaveEvent ifTrue:[ |
|
1397 pointerView := nil |
|
1398 ] |
|
1399 ] |
|
1400 ]. |
|
1401 |
1389 "/ |
1402 "/ |
1390 "/ keep track of which view has the pointer |
1403 "/ buttonPress events turn off explicit focus, and reverts |
1391 "/ |
1404 "/ to implicit focus control |
1392 event isPointerEnterEvent ifTrue:[ |
1405 "/ This used to be done for every click - |
1393 pointerView := evView |
1406 "/ but behaved ugly if clicking in a scrollbar ... |
|
1407 |
|
1408 "/ XXX: move to dispatchEvent |
|
1409 event isButtonPressEvent ifTrue:[ |
|
1410 (evView wantsFocusWithButtonPress) ifTrue:[ |
|
1411 "/ cannot use 'evView requestFocus' here, |
|
1412 "/ since we want to enforce it without giving the |
|
1413 "/ view a chance to circumvent this. |
|
1414 |
|
1415 "/ evView requestFocus. |
|
1416 self focusView:evView. |
|
1417 ]. |
|
1418 ]. |
|
1419 |
|
1420 LastActiveGroup := self. |
|
1421 LastActiveProcess := Processor activeProcess. |
|
1422 |
|
1423 (busyHook notNil and:[busyHookBlock isNil]) ifTrue:[ |
|
1424 (event isKeyEvent or:[event isButtonPressEvent]) ifTrue:[ |
|
1425 "/ start a timeout action - to invoke the busyHook after some time |
|
1426 busyHookBlock := [ busyHook value:true. busyHookCalled := true ]. |
|
1427 busyHookCalled := false. |
|
1428 Processor addTimedBlock:busyHookBlock afterMilliseconds:(busyHookTimeout ? BusyHookTime ? 150). |
|
1429 ]. |
|
1430 ]. |
|
1431 " |
|
1432 if there is no view information in the event, |
|
1433 it must have been sent directly to the sensor. |
|
1434 Send it to the first topView. |
|
1435 " |
|
1436 evView isNil ifTrue:[ |
|
1437 (firstTop := topViews first) notNil ifTrue:[ |
|
1438 "/ XXX: fix to dispatchEvent |
|
1439 firstTop perform:event type withArguments:event arguments |
|
1440 ] |
1394 ] ifFalse:[ |
1441 ] ifFalse:[ |
1395 event isPointerLeaveEvent ifTrue:[ |
1442 evView dispatchEvent:event withFocusOn:focus delegate:true |
1396 pointerView := nil |
|
1397 ] |
|
1398 ] |
|
1399 ]. |
|
1400 |
|
1401 "/ |
|
1402 "/ buttonPress events turn off explicit focus, and reverts |
|
1403 "/ to implicit focus control |
|
1404 "/ This used to be done for every click - |
|
1405 "/ but behaved ugly if clicking in a scrollbar ... |
|
1406 |
|
1407 "/ XXX: move to dispatchEvent |
|
1408 event isButtonPressEvent ifTrue:[ |
|
1409 (evView wantsFocusWithButtonPress) ifTrue:[ |
|
1410 "/ cannot use 'evView requestFocus' here, |
|
1411 "/ since we want to enforce it without giving the |
|
1412 "/ view a chance to circumvent this. |
|
1413 |
|
1414 "/ evView requestFocus. |
|
1415 self focusView:evView. |
|
1416 ]. |
1443 ]. |
1417 ]. |
1444 ]. |
1418 |
1445 |
1419 LastActiveGroup := self. |
1446 "/ give eventRecorders, postProcessors |
1420 LastActiveProcess := Processor activeProcess. |
1447 "/ a chance to see that event |
1421 |
1448 |
1422 (busyHook notNil and:[busyHookBlock isNil]) ifTrue:[ |
1449 postEventHook notNil ifTrue:[ |
1423 (event isKeyEvent or:[event isButtonPressEvent]) ifTrue:[ |
1450 postEventHook processEvent:event |
1424 "/ start a timeout action - to invoke the busyHook after some time |
|
1425 busyHookBlock := [ busyHook value:true. busyHookCalled := true ]. |
|
1426 busyHookCalled := false. |
|
1427 Processor addTimedBlock:busyHookBlock afterMilliseconds:(busyHookTimeout ? BusyHookTime ? 150). |
|
1428 ]. |
|
1429 ]. |
1451 ]. |
1430 " |
1452 ] |
1431 if there is no view information in the event, |
1453 ]. |
1432 it must have been sent directly to the sensor. |
|
1433 Send it to the first topView. |
|
1434 " |
|
1435 evView isNil ifTrue:[ |
|
1436 (firstTop := topViews first) notNil ifTrue:[ |
|
1437 "/ XXX: fix to dispatchEvent |
|
1438 firstTop perform:event type withArguments:event arguments |
|
1439 ] |
|
1440 ] ifFalse:[ |
|
1441 evView dispatchEvent:event withFocusOn:focus delegate:true |
|
1442 ]. |
|
1443 ]. |
|
1444 |
|
1445 "/ give eventRecorders, postProcessors |
|
1446 "/ a chance to see that event |
|
1447 |
|
1448 postEventHook notNil ifTrue:[ |
|
1449 postEventHook processEvent:event |
|
1450 ]. |
|
1451 ] |
|
1452 ]. |
1454 ]. |
1453 ]. |
1455 ] |
1454 |
1456 ] valueNowOrOnUnwindDo:[ |
1455 busyHookBlock notNil ifTrue:[ |
1457 busyHookBlock notNil ifTrue:[ |
1456 Processor removeTimedBlock:busyHookBlock. |
1458 Processor removeTimedBlock:busyHookBlock. |
1457 busyHookBlock := nil. |
1459 busyHookBlock := nil. |
1458 busyHookCalled ifTrue:[ |
1460 busyHookCalled ifTrue:[ |
1459 busyHook value:false. |
1461 busyHook value:false. |
1460 ] |
1462 ] |
1461 ]. |
1463 ]. |
1462 ] |
1464 ]. |
1463 |
1465 |
1464 "Created: / 5.3.1997 / 11:33:11 / cg" |
1466 "Created: / 5.3.1997 / 11:33:11 / cg" |
1465 "Modified: / 4.8.1998 / 18:18:55 / cg" |
1467 "Modified: / 4.8.1998 / 18:18:55 / cg" |
1466 ! |
1468 ! |
1467 |
1469 |