2481 or asynchronous communication between view applications |
2481 or asynchronous communication between view applications |
2482 (by sending arbitrary events, which leads to a message sent, |
2482 (by sending arbitrary events, which leads to a message sent, |
2483 when the target windowGroups process is rescheduled)." |
2483 when the target windowGroups process is rescheduled)." |
2484 |
2484 |
2485 anEvent timeStamp isNil ifTrue:[ |
2485 anEvent timeStamp isNil ifTrue:[ |
2486 anEvent timeStamp:(Timestamp now). |
2486 anEvent timeStamp:Timestamp now. |
2487 ]. |
2487 ]. |
2488 |
2488 |
2489 "/ inform all local and global eventListeners ? |
2489 "/ inform all local and global eventListeners ? |
2490 ("anyListenerReturnedTrue :=" self notifyEventListenersAbout:anEvent) ifTrue:[ |
2490 (self notifyEventListenersAbout:anEvent) ifTrue:[ |
2491 "/ event was eaten |
2491 "/ event was eaten |
2492 ^ self |
2492 ^ self |
2493 ]. |
2493 ]. |
2494 self basicPushEvent:anEvent. |
2494 self basicPushEvent:anEvent. |
2495 |
|
2496 "Created: / 18-09-1995 / 22:37:57 / claus" |
|
2497 "Modified: / 29-06-2011 / 18:57:19 / cg" |
|
2498 ! ! |
|
2499 |
|
2500 !WindowSensor methodsFor:'event simulation'! |
|
2501 |
|
2502 enqueueMessage:selector for:someone arguments:argList |
|
2503 "if such a message is already in the queue, ignore it. |
|
2504 Otherwise push it as an event, to be handled when my thread is |
|
2505 back in the event loop." |
|
2506 |
|
2507 self criticalUserEventQueueAccess:[ |
|
2508 (self hasUserEvent:selector for:someone withArguments:argList) ifFalse:[ |
|
2509 self pushUserEvent:selector for:someone withArguments:argList |
|
2510 ]. |
|
2511 ]. |
|
2512 ! |
|
2513 |
|
2514 forwardKeyEventsTo:aView |
|
2515 "remove all keyboard events and send them to aViews sensor instead" |
|
2516 |
|
2517 1 to:mouseAndKeyboard size do:[:i | |
|
2518 |anEvent| |
|
2519 |
|
2520 anEvent := mouseAndKeyboard at:i. |
|
2521 anEvent notNil ifTrue:[ |
|
2522 anEvent isKeyEvent ifTrue:[ |
|
2523 anEvent view:aView. |
|
2524 aView sensor pushEvent:anEvent. |
|
2525 mouseAndKeyboard at:i put:nil |
|
2526 ] |
|
2527 ] |
|
2528 ]. |
|
2529 |
|
2530 "Modified: 18.1.1997 / 14:05:02 / cg" |
|
2531 ! |
|
2532 |
|
2533 pushAction:aBlock |
|
2534 "enqueue an action into my event queue. |
|
2535 The underlying window process will evaluate aBlock in its event loop |
|
2536 (i.e. syncronously). Use this to present the result of an asyncronous background |
|
2537 computation" |
|
2538 |
|
2539 self pushUserEvent:#value for:aBlock withArguments:#() |
|
2540 ! |
|
2541 |
|
2542 pushUserEvent:aSelector for:aView |
|
2543 "manually put an event into the queue - this allows |
|
2544 simulation of events (implementation of recorders & playback) |
|
2545 or asynchronous communication between view applications. |
|
2546 The view will perform a method as specified by aSelector, |
|
2547 when it performs event processing; this is different than sending |
|
2548 this message directly, since the execution is done by the views process, |
|
2549 not by the current process (which is especially worthwhile, if that method |
|
2550 shows a modal box or similar)." |
|
2551 |
|
2552 self pushUserEvent:aSelector for:aView withArguments:#() |
|
2553 |
|
2554 "Modified: 18.9.1995 / 22:40:12 / claus" |
|
2555 ! |
|
2556 |
|
2557 pushUserEvent:aSelector for:anyObject withArgument:argument |
|
2558 "manually put an event into the queue - this allows |
|
2559 simulation of events (implementation of recorders & playback) |
|
2560 or asynchronous communication between view applications. |
|
2561 anyObject will perform a method as specified by aSelector, |
|
2562 when the windogroup dispatches this event. This is different than sending |
|
2563 this message directly, since the execution is done by the views process, |
|
2564 not by the current process (which is especially worthwhile, if that method |
|
2565 shows a modal box or similar)." |
|
2566 |
|
2567 self pushUserEvent:aSelector for:anyObject withArguments:(Array with:argument). |
|
2568 ! |
|
2569 |
|
2570 pushUserEvent:aSelector for:anyObject withArguments:arguments |
|
2571 "manually put an event into the queue - this allows |
|
2572 simulation of events (implementation of recorders & playback) |
|
2573 or asynchronous communication between view applications. |
|
2574 anyObject will perform a method as specified by aSelector, |
|
2575 when the windogroup dispatches this event. This is different than sending |
|
2576 this message directly, since the execution is done by the views process, |
|
2577 not by the current process (which is especially worthwhile, if that method |
|
2578 shows a modal box or similar)." |
|
2579 |
|
2580 self pushEvent:(WindowEvent messageSend:anyObject selector:aSelector arguments:arguments). |
|
2581 |
2495 |
2582 " |
2496 " |
2583 |b| |
2497 |b| |
2584 b := Button label:'test'. |
2498 b := Button label:'test'. |
2585 b action:[Transcript showCR:'hallo']. |
2499 b action:[Transcript showCR:'hallo']. |
2591 (Delay forSeconds:2) wait. |
2505 (Delay forSeconds:2) wait. |
2592 b sensor pushEvent:(WindowEvent buttonRelease:1 x:1 y:1 view:b). |
2506 b sensor pushEvent:(WindowEvent buttonRelease:1 x:1 y:1 view:b). |
2593 (Delay forSeconds:1) wait. |
2507 (Delay forSeconds:1) wait. |
2594 b sensor pushEvent:(WindowEvent pointerLeave:0 view:b). |
2508 b sensor pushEvent:(WindowEvent pointerLeave:0 view:b). |
2595 " |
2509 " |
|
2510 |
|
2511 "Created: / 18-09-1995 / 22:37:57 / claus" |
|
2512 "Modified: / 29-06-2011 / 18:57:19 / cg" |
|
2513 ! ! |
|
2514 |
|
2515 !WindowSensor methodsFor:'event simulation'! |
|
2516 |
|
2517 enqueueMessage:selector for:someone arguments:argList |
|
2518 "if such a message is already in the queue, ignore it. |
|
2519 Otherwise push it as an event, to be handled when my thread is |
|
2520 back in the event loop." |
|
2521 |
|
2522 self criticalUserEventQueueAccess:[ |
|
2523 (self hasUserEvent:selector for:someone withArguments:argList) ifFalse:[ |
|
2524 self pushUserEvent:selector for:someone withArguments:argList |
|
2525 ]. |
|
2526 ]. |
|
2527 ! |
|
2528 |
|
2529 forwardKeyEventsTo:aView |
|
2530 "remove all keyboard events and send them to aViews sensor instead" |
|
2531 |
|
2532 1 to:mouseAndKeyboard size do:[:i | |
|
2533 |anEvent| |
|
2534 |
|
2535 anEvent := mouseAndKeyboard at:i. |
|
2536 anEvent notNil ifTrue:[ |
|
2537 anEvent isKeyEvent ifTrue:[ |
|
2538 anEvent view:aView. |
|
2539 aView sensor pushEvent:anEvent. |
|
2540 mouseAndKeyboard at:i put:nil |
|
2541 ] |
|
2542 ] |
|
2543 ]. |
|
2544 |
|
2545 "Modified: 18.1.1997 / 14:05:02 / cg" |
|
2546 ! |
|
2547 |
|
2548 pushAction:aBlock |
|
2549 "enqueue an action into my event queue. |
|
2550 The underlying window process will evaluate aBlock in its event loop |
|
2551 (i.e. syncronously). Use this to present the result of an asyncronous background |
|
2552 computation" |
|
2553 |
|
2554 self pushUserEvent:#value for:aBlock withArguments:#() |
|
2555 ! |
|
2556 |
|
2557 pushUserEvent:aSelector for:aView |
|
2558 "manually put an event into the queue - this allows |
|
2559 simulation of events (implementation of recorders & playback) |
|
2560 or asynchronous communication between view applications. |
|
2561 The view will perform a method as specified by aSelector, |
|
2562 when it performs event processing; this is different than sending |
|
2563 this message directly, since the execution is done by the views process, |
|
2564 not by the current process (which is especially worthwhile, if that method |
|
2565 shows a modal box or similar)." |
|
2566 |
|
2567 self pushUserEvent:aSelector for:aView withArguments:#() |
|
2568 |
|
2569 "Modified: 18.9.1995 / 22:40:12 / claus" |
|
2570 ! |
|
2571 |
|
2572 pushUserEvent:aSelector for:anyObject withArgument:argument |
|
2573 "manually put an event into the queue - this allows |
|
2574 simulation of events (implementation of recorders & playback) |
|
2575 or asynchronous communication between view applications. |
|
2576 anyObject will perform a method as specified by aSelector, |
|
2577 when the windogroup dispatches this event. This is different than sending |
|
2578 this message directly, since the execution is done by the views process, |
|
2579 not by the current process (which is especially worthwhile, if that method |
|
2580 shows a modal box or similar)." |
|
2581 |
|
2582 self pushUserEvent:aSelector for:anyObject withArguments:(Array with:argument). |
|
2583 ! |
|
2584 |
|
2585 pushUserEvent:aSelector for:anyObject withArguments:arguments |
|
2586 "manually put an event into the queue - this allows |
|
2587 simulation of events (implementation of recorders & playback) |
|
2588 or asynchronous communication between view applications. |
|
2589 anyObject will perform a method as specified by aSelector, |
|
2590 when the windogroup dispatches this event. This is different than sending |
|
2591 this message directly, since the execution is done by the views process, |
|
2592 not by the current process (which is especially worthwhile, if that method |
|
2593 shows a modal box or similar)." |
|
2594 |
|
2595 self pushEvent:(WindowEvent messageSend:anyObject selector:aSelector arguments:arguments). |
2596 |
2596 |
2597 " |
2597 " |
2598 |b| |
2598 |b| |
2599 b := Button label:'test'. |
2599 b := Button label:'test'. |
2600 b open. |
2600 b open. |