1377 eventReceiver controller deviceMessage |
1377 eventReceiver controller deviceMessage |
1378 isKeyEvent isButtonEvent isMouseWheelEvent isPointerEvent |
1378 isKeyEvent isButtonEvent isMouseWheelEvent isPointerEvent |
1379 rect x y w h delegatedEvent rgn| |
1379 rect x y w h delegatedEvent rgn| |
1380 |
1380 |
1381 type == #damage ifTrue:[ |
1381 type == #damage ifTrue:[ |
1382 "/ OLDdamage scheme - this will vanish |
1382 "/ OLDdamage scheme - this will vanish |
1383 self shown ifTrue:[ |
1383 self shown ifTrue:[ |
1384 rect := argArray. |
1384 rect := argArray. |
1385 x := rect left. |
1385 x := rect left. |
1386 y := rect top. |
1386 y := rect top. |
1387 w := rect width. |
1387 w := rect width. |
1388 h := rect height. |
1388 h := rect height. |
1389 transformation notNil ifTrue:[ |
1389 transformation notNil ifTrue:[ |
1390 self deviceExposeX:x y:y width:w height:h |
1390 self deviceExposeX:x y:y width:w height:h |
1391 ] ifFalse:[ |
1391 ] ifFalse:[ |
1392 self exposeX:x y:y width:w height:h |
1392 self exposeX:x y:y width:w height:h |
1393 ] |
1393 ] |
1394 ]. |
1394 ]. |
1395 ^ self |
1395 ^ self |
1396 ]. |
1396 ]. |
1397 |
1397 |
1398 type == #newDamage ifTrue:[ |
1398 type == #newDamage ifTrue:[ |
1399 "/ New damage scheme |
1399 "/ New damage scheme |
1400 rgn := updateRegion. |
1400 rgn := updateRegion. |
1401 updateRegion := nil. |
1401 updateRegion := nil. |
1402 self shown ifTrue:[ |
1402 self shown ifTrue:[ |
1403 rgn notNil ifTrue:[ |
1403 rgn notNil ifTrue:[ |
1404 rgn do:[:rect | |
1404 rgn do:[:rect | |
1405 "/ cg: I think the check for being realized may not be enough; |
1405 "/ cg: I think the check for being realized may not be enough; |
1406 "/ there is a race here, if the view gets closed, while in the loop... |
1406 "/ there is a race here, if the view gets closed, while in the loop... |
1407 realized ifTrue:[ |
1407 realized ifTrue:[ |
1408 x := rect left. |
1408 x := rect left. |
1409 y := rect top. |
1409 y := rect top. |
1410 w := rect width. |
1410 w := rect width. |
1411 h := rect height. |
1411 h := rect height. |
1412 transformation notNil ifTrue:[ |
1412 transformation notNil ifTrue:[ |
1413 self deviceExposeX:x y:y width:w height:h |
1413 self deviceExposeX:x y:y width:w height:h |
1414 ] ifFalse:[ |
1414 ] ifFalse:[ |
1415 self exposeX:x y:y width:w height:h |
1415 self exposeX:x y:y width:w height:h |
1416 ] |
1416 ] |
1417 ] |
1417 ] |
1418 ] |
1418 ] |
1419 ] |
1419 ] |
1420 ]. |
1420 ]. |
1421 ^ self |
1421 ^ self |
1422 ]. |
1422 ]. |
1423 |
1423 |
1424 isKeyEvent := isButtonEvent := isPointerEvent := isMouseWheelEvent := false. |
1424 isKeyEvent := isButtonEvent := isPointerEvent := isMouseWheelEvent := false. |
1425 |
1425 |
1426 (type == #'keyPress:x:y:') ifTrue:[ |
1426 (type == #'keyPress:x:y:') ifTrue:[ |
1427 isKeyEvent := true. |
1427 isKeyEvent := true. |
1428 deviceMessage := #'deviceKeyPress:x:y:'. |
1428 deviceMessage := #'deviceKeyPress:x:y:'. |
1429 delegateMessage := #'keyPress:x:y:view:'. |
1429 delegateMessage := #'keyPress:x:y:view:'. |
1430 delegateQuery := #'handlesKeyPress:inView:'. |
1430 delegateQuery := #'handlesKeyPress:inView:'. |
1431 ] ifFalse:[ (type == #'keyRelease:x:y:') ifTrue:[ |
1431 ] ifFalse:[ (type == #'keyRelease:x:y:') ifTrue:[ |
1432 isKeyEvent := true. |
1432 isKeyEvent := true. |
1433 deviceMessage := #'deviceKeyRelease:x:y:'. |
1433 deviceMessage := #'deviceKeyRelease:x:y:'. |
1434 delegateMessage := #'keyRelease:x:y:view:'. |
1434 delegateMessage := #'keyRelease:x:y:view:'. |
1435 delegateQuery := #'handlesKeyRelease:inView:'. |
1435 delegateQuery := #'handlesKeyRelease:inView:'. |
1436 ] ifFalse:[ (type == #'buttonMotion:x:y:') ifTrue:[ |
1436 ] ifFalse:[ (type == #'buttonMotion:x:y:') ifTrue:[ |
1437 isButtonEvent := true. |
1437 isButtonEvent := true. |
1438 deviceMessage := #'deviceButtonMotion:x:y:'. |
1438 deviceMessage := #'deviceButtonMotion:x:y:'. |
1439 delegateMessage := #'buttonMotion:x:y:view:'. |
1439 delegateMessage := #'buttonMotion:x:y:view:'. |
1440 delegateQuery := #'handlesButtonMotion:inView:'. |
1440 delegateQuery := #'handlesButtonMotion:inView:'. |
1441 ] ifFalse:[ (type == #'buttonPress:x:y:') ifTrue:[ |
1441 ] ifFalse:[ (type == #'buttonPress:x:y:') ifTrue:[ |
1442 isButtonEvent := true. |
1442 isButtonEvent := true. |
1443 deviceMessage := #'deviceButtonPress:x:y:'. |
1443 deviceMessage := #'deviceButtonPress:x:y:'. |
1444 delegateMessage := #'buttonPress:x:y:view:'. |
1444 delegateMessage := #'buttonPress:x:y:view:'. |
1445 delegateQuery := #'handlesButtonPress:inView:'. |
1445 delegateQuery := #'handlesButtonPress:inView:'. |
1446 ] ifFalse:[ (type == #'buttonRelease:x:y:') ifTrue:[ |
1446 ] ifFalse:[ (type == #'buttonRelease:x:y:') ifTrue:[ |
1447 isButtonEvent := true. |
1447 isButtonEvent := true. |
1448 deviceMessage := #'deviceButtonRelease:x:y:'. |
1448 deviceMessage := #'deviceButtonRelease:x:y:'. |
1449 delegateMessage := #'buttonRelease:x:y:view:'. |
1449 delegateMessage := #'buttonRelease:x:y:view:'. |
1450 delegateQuery := #'handlesButtonRelease:inView:'. |
1450 delegateQuery := #'handlesButtonRelease:inView:'. |
1451 ] ifFalse:[ (type == #'buttonShiftPress:x:y:') ifTrue:[ |
1451 ] ifFalse:[ (type == #'buttonShiftPress:x:y:') ifTrue:[ |
1452 isButtonEvent := true. |
1452 isButtonEvent := true. |
1453 deviceMessage := #'deviceButtonShiftPress:x:y:'. |
1453 deviceMessage := #'deviceButtonShiftPress:x:y:'. |
1454 delegateMessage := #'buttonShiftPress:x:y:view:'. |
1454 delegateMessage := #'buttonShiftPress:x:y:view:'. |
1455 delegateQuery := #'handlesButtonShiftPress:inView:'. |
1455 delegateQuery := #'handlesButtonShiftPress:inView:'. |
1456 ] ifFalse:[ (type == #'buttonMultiPress:x:y:') ifTrue:[ |
1456 ] ifFalse:[ (type == #'buttonMultiPress:x:y:') ifTrue:[ |
1457 isButtonEvent := true. |
1457 isButtonEvent := true. |
1458 deviceMessage := #'deviceButtonMultiPress:x:y:'. |
1458 deviceMessage := #'deviceButtonMultiPress:x:y:'. |
1459 delegateMessage := #'buttonMultiPress:x:y:view:'. |
1459 delegateMessage := #'buttonMultiPress:x:y:view:'. |
1460 delegateQuery := #'handlesButtonMultiPress:inView:'. |
1460 delegateQuery := #'handlesButtonMultiPress:inView:'. |
1461 ] ifFalse:[ (type == #mouseWheelMotion:x:y:amount:deltaTime:) ifTrue:[ |
1461 ] ifFalse:[ (type == #mouseWheelMotion:x:y:amount:deltaTime:) ifTrue:[ |
1462 isMouseWheelEvent := true. |
1462 isMouseWheelEvent := true. |
1463 deviceMessage := type. |
1463 deviceMessage := type. |
1464 delegateMessage := #mouseWheelMotion:x:y:amount:deltaTime:view:. |
1464 delegateMessage := #mouseWheelMotion:x:y:amount:deltaTime:view:. |
1465 delegateQuery := #handlesMouseWheelMotion:inView:. |
1465 delegateQuery := #handlesMouseWheelMotion:inView:. |
1466 ] ifFalse:[ (type == #'pointerEnter:x:y:') ifTrue:[ |
1466 ] ifFalse:[ (type == #'pointerEnter:x:y:') ifTrue:[ |
1467 isPointerEvent := true. |
1467 isPointerEvent := true. |
1468 deviceMessage := #'devicePointerEnter:x:y:'. |
1468 deviceMessage := #'devicePointerEnter:x:y:'. |
1469 delegateMessage := #'pointerEnter:x:y:view:'. |
1469 delegateMessage := #'pointerEnter:x:y:view:'. |
1470 delegateQuery := #'handlesPointerEnter:inView:'. |
1470 delegateQuery := #'handlesPointerEnter:inView:'. |
1471 ] ifFalse:[ (type == #'pointerLeave:') ifTrue:[ |
1471 ] ifFalse:[ (type == #'pointerLeave:') ifTrue:[ |
1472 isPointerEvent := true. |
1472 isPointerEvent := true. |
1473 deviceMessage := type. |
1473 deviceMessage := type. |
1474 delegateMessage := #'pointerLeave:view:'. |
1474 delegateMessage := #'pointerLeave:view:'. |
1475 delegateQuery := #'handlesPointerLeave:inView:'. |
1475 delegateQuery := #'handlesPointerLeave:inView:'. |
1476 ] ifFalse:[ (type == #'exposeX:y:width:height:') ifTrue:[ |
1476 ] ifFalse:[ (type == #'exposeX:y:width:height:') ifTrue:[ |
1477 deviceMessage := #'deviceExposeX:y:width:height:'. |
1477 deviceMessage := #'deviceExposeX:y:width:height:'. |
1478 ] ifFalse:[ (type == #'graphicsExposeX:y:width:height:final:') ifTrue:[ |
1478 ] ifFalse:[ (type == #'graphicsExposeX:y:width:height:final:') ifTrue:[ |
1479 deviceMessage := #'deviceGraphicsExposeX:y:width:height:final:'. |
1479 deviceMessage := #'deviceGraphicsExposeX:y:width:height:final:'. |
1480 ]]]]]]]]]]]]. |
1480 ]]]]]]]]]]]]. |
1481 |
1481 |
1482 " |
1482 " |
1483 if there is a focusView, and its a keyboard event, pass it |
1483 if there is a focusView, and its a keyboard event, pass it |
1484 to that view (or its controller, or its delegate). |
1484 to that view (or its controller, or its delegate). |
1485 In this case, a coordinate which is outside of |
1485 In this case, a coordinate which is outside of |
1486 the focusView (0 @ 0) is passed as x/y coordinates. |
1486 the focusView (0 @ 0) is passed as x/y coordinates. |
1487 " |
1487 " |
1488 ((isKeyEvent "or:[isMouseWheelEvent]") |
1488 ((isKeyEvent "or:[isMouseWheelEvent]") |
1489 and:[focusView notNil and:[self ~~ focusView]]) ifTrue:[ |
1489 and:[focusView notNil and:[self ~~ focusView]]) ifTrue:[ |
1490 delegatedEvent := ev shallowCopy. |
1490 delegatedEvent := ev shallowCopy. |
1491 delegatedEvent delegatedFrom:ev. |
1491 delegatedEvent delegatedFrom:ev. |
1492 delegatedEvent arguments:(ev arguments shallowCopy). |
1492 delegatedEvent arguments:(ev arguments shallowCopy). |
1493 delegatedEvent x:-1; y:-1. |
1493 delegatedEvent x:-1; y:-1. |
1494 |
1494 |
1495 focusView |
1495 focusView |
1496 dispatchEvent:delegatedEvent |
1496 dispatchEvent:delegatedEvent |
1497 withFocusOn:nil |
1497 withFocusOn:nil |
1498 delegate:doDelegate. |
1498 delegate:doDelegate. |
1499 ^ self |
1499 ^ self |
1500 ]. |
1500 ]. |
1501 |
1501 |
1502 doDelegate ifTrue:[ |
1502 doDelegate ifTrue:[ |
1503 " |
1503 " |
1504 handle delegated messages |
1504 handle delegated messages |
1505 " |
1505 " |
1506 (isKeyEvent |
1506 (isKeyEvent |
1507 or:[isButtonEvent |
1507 or:[isButtonEvent |
1508 or:[isMouseWheelEvent |
1508 or:[isMouseWheelEvent |
1509 or:[isPointerEvent]]]) ifTrue:[ |
1509 or:[isPointerEvent]]]) ifTrue:[ |
1510 delegate := self delegate. |
1510 delegate := self delegate. |
1511 |
1511 |
1512 " |
1512 " |
1513 what a kludge - sending to delegate requires |
1513 what a kludge - sending to delegate requires |
1514 another selector and an additional argument ... |
1514 another selector and an additional argument ... |
1515 " |
1515 " |
1516 (delegate notNil) ifTrue:[ |
1516 (delegate notNil) ifTrue:[ |
1517 " |
1517 " |
1518 is the delegate interested in that event ? |
1518 is the delegate interested in that event ? |
1519 (if it does not respond to the handlesXXX message, assume: NO) |
1519 (if it does not respond to the handlesXXX message, assume: NO) |
1520 " |
1520 " |
1521 (delegate askFor:delegateQuery with:(argArray at:1) with:self) ifTrue:[ |
1521 (delegate askFor:delegateQuery with:(argArray at:1) with:self) ifTrue:[ |
1522 " |
1522 " |
1523 mhmh ... have to convert to logical coordinates |
1523 mhmh ... have to convert to logical coordinates |
1524 " |
1524 " |
1525 transformation notNil ifTrue:[ |
1525 transformation notNil ifTrue:[ |
1526 argArray size > 2 ifTrue:[ |
1526 argArray size > 2 ifTrue:[ |
1527 argArray at:2 put:(transformation applyInverseToX:(argArray at:2)). |
1527 argArray at:2 put:(transformation applyInverseToX:(argArray at:2)). |
1528 argArray at:3 put:(transformation applyInverseToY:(argArray at:3)). |
1528 argArray at:3 put:(transformation applyInverseToY:(argArray at:3)). |
1529 ]. |
1529 ]. |
1530 ]. |
1530 ]. |
1531 argArray isNil ifTrue:[ |
1531 argArray isNil ifTrue:[ |
1532 delegate perform:delegateMessage with:self |
1532 delegate perform:delegateMessage with:self |
1533 ] ifFalse:[ |
1533 ] ifFalse:[ |
1534 delegate perform:delegateMessage withArguments:(argArray copyWith:self) |
1534 delegate perform:delegateMessage withArguments:(argArray copyWith:self) |
1535 ]. |
1535 ]. |
1536 ^ self |
1536 ^ self |
1537 ] |
1537 ] |
1538 ]. |
1538 ]. |
1539 ]. |
1539 ]. |
1540 ]. |
1540 ]. |
1541 |
1541 |
1542 " |
1542 " |
1543 if I am not shown, ignore input events |
1543 if I am not shown, ignore input events |
1544 " |
1544 " |
1545 (isKeyEvent |
1545 (isKeyEvent |
1546 or:[isButtonEvent |
1546 or:[isButtonEvent |
1547 or:[isMouseWheelEvent |
1547 or:[isMouseWheelEvent |
1548 or:[isPointerEvent]]]) ifTrue:[ |
1548 or:[isPointerEvent]]]) ifTrue:[ |
1549 realized ifFalse:[ |
1549 realized ifFalse:[ |
1550 ^ self |
1550 ^ self |
1551 ] |
1551 ] |
1552 ]. |
1552 ]. |
1553 |
1553 |
1554 " |
1554 " |
1555 if there is a controller, that one gets all user events |
1555 if there is a controller, that one gets all user events |
1556 " |
1556 " |
1557 eventReceiver := self. |
1557 eventReceiver := self. |
1558 (controller := self controller) notNil ifTrue:[ |
1558 (controller := self controller) notNil ifTrue:[ |
1559 (isKeyEvent |
1559 (isKeyEvent |
1560 or:[isButtonEvent |
1560 or:[isButtonEvent |
1561 or:[isMouseWheelEvent |
1561 or:[isMouseWheelEvent |
1562 or:[isPointerEvent |
1562 or:[isPointerEvent |
1563 or:[(type == #focusIn) |
1563 or:[(type == #focusIn) |
1564 or:[(type == #focusOut)]]]]]) ifTrue:[ |
1564 or:[(type == #focusOut)]]]]]) ifTrue:[ |
1565 eventReceiver := controller. |
1565 eventReceiver := controller. |
1566 ] |
1566 ] |
1567 ]. |
1567 ]. |
1568 |
1568 |
1569 " |
1569 " |
1570 finally, another one: |
1570 finally, another one: |
1571 if I have a transformation, edit the selector from #foo to #deviceFoo... |
1571 if I have a transformation, edit the selector from #foo to #deviceFoo... |