52 ! ! |
52 ! ! |
53 |
53 |
54 !ShowMeHowItWorks class methodsFor:'running'! |
54 !ShowMeHowItWorks class methodsFor:'running'! |
55 |
55 |
56 do:specArray |
56 do:specArray |
57 self doStream:specArray readStream |
|
58 |
|
59 "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
60 "Modified: / 19-07-2019 / 14:30:43 / Claus Gittinger" |
|
61 ! |
|
62 |
|
63 doStream:specStream |
|
64 "must run as a separate process; |
57 "must run as a separate process; |
65 otherwise - if started by the app itself - |
58 otherwise - if started by the app itself - |
66 no events will be processed while running" |
59 no events will be processed while running" |
67 |
60 |
68 |appWhichStartedMe| |
61 |appWhichStartedMe| |
69 |
62 |
70 appWhichStartedMe := WindowGroup activeMainApplication. |
63 appWhichStartedMe := WindowGroup activeMainApplication. |
71 |
64 |
72 [ |
65 [ |
73 self new |
66 Error handle:[:ex | |
74 application:appWhichStartedMe; |
67 Dialog warn:(self classResources stringWithCRs:'An error was encountered in the show:\\%1' with:ex description) |
75 doStream:specStream |
68 ] do:[ |
|
69 self new |
|
70 application:appWhichStartedMe; |
|
71 doStream:(specArray readStream) |
|
72 ]. |
76 ] fork. |
73 ] fork. |
77 |
74 |
78 "Created: / 19-07-2019 / 10:53:07 / Claus Gittinger" |
75 " |
79 "Modified: / 19-07-2019 / 16:44:02 / Claus Gittinger" |
76 ShowMeHowItWorks do: |
|
77 #( |
|
78 (show: 'bla bla') |
|
79 (moveTo: NameOfComponent) |
|
80 ) |
|
81 " |
|
82 |
|
83 "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
|
84 "Modified: / 23-07-2019 / 09:19:40 / Claus Gittinger" |
80 ! ! |
85 ! ! |
81 |
86 |
82 !ShowMeHowItWorks methodsFor:'accessing'! |
87 !ShowMeHowItWorks methodsFor:'accessing'! |
83 |
88 |
84 application:something |
89 application:something |
255 |component| |
260 |component| |
256 |
261 |
257 component := self componentNamed:componentName. |
262 component := self componentNamed:componentName. |
258 self movePointerToComponent:component speed:(self pointerMoveSpeedFast). |
263 self movePointerToComponent:component speed:(self pointerMoveSpeedFast). |
259 |
264 |
|
265 " |
|
266 ShowMeHowItWorks basicNew fastMoveTo:'Classes' |
|
267 ShowMeHowItWorks basicNew fastMoveTo:'Klassen' |
|
268 " |
|
269 |
260 "Created: / 19-07-2019 / 15:39:23 / Claus Gittinger" |
270 "Created: / 19-07-2019 / 15:39:23 / Claus Gittinger" |
261 "Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger" |
271 "Modified: / 20-07-2019 / 08:14:16 / Claus Gittinger" |
|
272 "Modified (comment): / 23-07-2019 / 09:33:31 / Claus Gittinger" |
262 ! |
273 ! |
263 |
274 |
264 moveTo:componentName |
275 moveTo:componentName |
265 "move the mouse to componentName, |
276 "move the mouse to componentName, |
266 then circle around it a few times" |
277 then circle around it a few times" |
476 |
487 |
477 "Created: / 19-07-2019 / 15:21:29 / Claus Gittinger" |
488 "Created: / 19-07-2019 / 15:21:29 / Claus Gittinger" |
478 ! |
489 ! |
479 |
490 |
480 talking |
491 talking |
|
492 "/ ^ Expecco::ExpeccoPreferences current speechEffectsEnabled |
481 ^ true |
493 ^ true |
482 |
494 |
483 "Created: / 19-07-2019 / 14:31:14 / Claus Gittinger" |
495 "Created: / 19-07-2019 / 14:31:14 / Claus Gittinger" |
|
496 "Modified (comment): / 23-07-2019 / 09:45:35 / Claus Gittinger" |
484 ! ! |
497 ! ! |
485 |
498 |
486 !ShowMeHowItWorks methodsFor:'helper'! |
499 !ShowMeHowItWorks methodsFor:'helper'! |
487 |
500 |
|
501 randomThankYou |
|
502 ^ #( |
|
503 'thank you, for watching' |
|
504 'thank you for watching' |
|
505 'thank you' |
|
506 'have a good day' |
|
507 'have fun' |
|
508 'have fun with expecco' |
|
509 'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: "to sin"' |
|
510 'happy hacking' |
|
511 'happy hacking, I hope you liked what you saw' |
|
512 'hope you liked it' |
|
513 'see you again' |
|
514 'please give feedback, and let us know, if you liked it' |
|
515 'if you have any questions, please contact exept' |
|
516 'if you need more information, please take a look at the wiki' |
|
517 ) atRandom |
|
518 |
|
519 " |
|
520 OperatingSystem speak:'have fun with expecco' |
|
521 OperatingSystem speak:'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: to sin' |
|
522 OperatingSystem speak:'happy hacking, I hope you liked what you saw' |
|
523 OperatingSystem speak:'please give feedback, and let us know, if you liked it' |
|
524 OperatingSystem speak:'if you have any questions, please contact exept' |
|
525 OperatingSystem speak:'if you need more information, please take a look at the wiki' |
|
526 " |
|
527 |
|
528 "Created: / 19-07-2019 / 21:39:18 / Claus Gittinger" |
|
529 ! |
|
530 |
|
531 tell:message |
|
532 self talking ifTrue:[ |
|
533 OperatingSystem speak:message. |
|
534 ]. |
|
535 |
|
536 "Created: / 19-07-2019 / 14:57:50 / Claus Gittinger" |
|
537 ! ! |
|
538 |
|
539 !ShowMeHowItWorks methodsFor:'helpers - broken'! |
|
540 |
|
541 click:buttonNr atPosition:position |
|
542 "press-release at position" |
|
543 |
|
544 |screen| |
|
545 |
|
546 screen := Screen current. |
|
547 |
|
548 screen setPointerPosition:position. |
|
549 screen flush. |
|
550 self click:buttonNr |
|
551 |
|
552 "Created: / 19-07-2019 / 13:14:51 / Claus Gittinger" |
|
553 ! ! |
|
554 |
|
555 !ShowMeHowItWorks methodsFor:'helpers - component search'! |
|
556 |
488 componentNamed:componentName |
557 componentNamed:componentName |
489 "retrieve a component by name or report an error if not found" |
558 "retrieve a component by name or report an error if not found. |
|
559 Can return either a view or a menu item" |
490 |
560 |
491 |component| |
561 |component| |
492 |
562 |
493 lastComponentName := componentName. |
563 lastComponentName := componentName. |
494 |
564 |
498 ]. |
568 ]. |
499 lastComponent := component. |
569 lastComponent := component. |
500 ^ component |
570 ^ component |
501 |
571 |
502 "Created: / 19-07-2019 / 15:37:35 / Claus Gittinger" |
572 "Created: / 19-07-2019 / 15:37:35 / Claus Gittinger" |
|
573 "Modified (comment): / 23-07-2019 / 09:31:53 / Claus Gittinger" |
503 ! |
574 ! |
504 |
575 |
505 findComponent:componentName |
576 findComponent:componentName |
506 "find a component by name - in the active and possibly in any app" |
577 "find a component by name - in the active and possibly in any app. |
|
578 Can return either a view or a menu item" |
507 |
579 |
508 |component candidates| |
580 |component candidates| |
509 |
581 |
510 application notNil ifTrue:[ |
582 application notNil ifTrue:[ |
511 component := self findComponent:componentName in:application. |
583 component := self findComponent:componentName in:application. |
533 ] |
605 ] |
534 ]. |
606 ]. |
535 ]. |
607 ]. |
536 ^ component |
608 ^ component |
537 |
609 |
|
610 " |
|
611 ShowMeHowItWorks basicNew findComponent:'Classes' |
|
612 ShowMeHowItWorks basicNew findComponent:'Klassen' |
|
613 " |
|
614 |
538 "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger" |
615 "Created: / 19-07-2019 / 12:02:30 / Claus Gittinger" |
539 "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger" |
616 "Modified: / 19-07-2019 / 16:44:30 / Claus Gittinger" |
540 ! |
617 "Modified (comment): / 23-07-2019 / 09:32:44 / Claus Gittinger" |
541 |
618 ! |
542 findComponent:componentName in:anApplication |
619 |
543 |component componentNameSymbol foundByName foundByTitle foundByLabel| |
620 findComponent:componentName in:anApplicationOrView |
544 |
621 "find a component by name inside an app. |
545 (component := anApplication componentAt:componentName) notNil ifTrue:[^ component]. |
622 Uses the NameKey of the spec, and optionally the label or modelKey. |
546 (componentNameSymbol := componentName asSymbolIfInterned) notNil ifTrue:[ |
623 Can return either a view or a menu item" |
547 (component := anApplication componentAt:componentNameSymbol) notNil ifTrue:[^ component]. |
624 |
548 ]. |
625 |app window component componentNameSymbol foundByName foundByTitle foundByLabel item| |
|
626 |
|
627 (app := anApplicationOrView) isView ifTrue:[ |
|
628 window := anApplicationOrView. |
|
629 app := anApplicationOrView application |
|
630 ]. |
|
631 app notNil ifTrue:[ |
|
632 (component := app componentAt:componentName) notNil ifTrue:[^ component]. |
|
633 (componentNameSymbol := componentName asSymbolIfInterned) notNil ifTrue:[ |
|
634 (component := app componentAt:componentNameSymbol) notNil ifTrue:[^ component]. |
|
635 ]. |
|
636 window := app window. |
|
637 ]. |
549 |
638 |
550 "/ mhmh - search through all widgets of anApplication; |
639 "/ mhmh - search through all widgets of anApplication; |
551 "/ maybe it was not created via the builder/spec, |
640 "/ maybe it was not created via the builder/spec, |
552 "/ or it has changed its name. |
641 "/ or it has changed its name. |
553 "/ look for: widget's name, widget's title, widget's label |
642 "/ look for: widget's name, widget's title, widget's label |
554 foundByName := OrderedCollection new. |
643 foundByName := OrderedCollection new. |
555 foundByTitle := OrderedCollection new. |
644 foundByTitle := OrderedCollection new. |
556 foundByLabel := OrderedCollection new. |
645 foundByLabel := OrderedCollection new. |
557 |
646 |
558 anApplication window allSubViewsDo:[:each | |
647 window allSubViewsDo:[:each | |
|
648 |foundIt| |
|
649 |
|
650 foundIt := false. |
559 [ |
651 [ |
560 each name = componentName ifTrue:[ foundByName add:each ]. |
652 each name = componentName ifTrue:[ foundByName add:each. foundIt := true ]. |
561 ] on:MessageNotUnderstood do:[:ex | ]. |
653 ] on:MessageNotUnderstood do:[:ex | ]. |
562 [ |
654 foundIt ifFalse:[ |
563 each title = componentName ifTrue:[ foundByTitle add:each ]. |
655 [ |
564 ] on:MessageNotUnderstood do:[:ex | ]. |
656 each title = componentName ifTrue:[ foundByTitle add:each. foundIt := true ]. |
565 [ |
657 ] on:MessageNotUnderstood do:[:ex | ]. |
566 each label = componentName ifTrue:[ foundByLabel add:each ]. |
658 foundIt ifFalse:[ |
567 ] on:MessageNotUnderstood do:[:ex | ]. |
659 [ |
568 ]. |
660 each label = componentName ifTrue:[ foundByLabel add:each. foundIt := true ]. |
|
661 ] on:MessageNotUnderstood do:[:ex | ]. |
|
662 foundIt ifFalse:[ |
|
663 each isMenu ifTrue:[ |
|
664 (item := each detectItemForNameKey:componentName) notNil ifTrue:[ |
|
665 foundByName add:item. foundIt := true |
|
666 ]. |
|
667 foundIt ifFalse:[ |
|
668 (item := each detectItemForKey:componentName) notNil ifTrue:[ |
|
669 foundByName add:item. foundIt := true |
|
670 ]. |
|
671 foundIt ifFalse:[ |
|
672 (item := each detectItemForLabel:componentName) notNil ifTrue:[ |
|
673 foundByLabel add:item. foundIt := true |
|
674 ]. |
|
675 ]. |
|
676 ]. |
|
677 ]. |
|
678 ]. |
|
679 ] |
|
680 ]. |
|
681 ]. |
|
682 |
569 foundByName notEmpty ifTrue:[ |
683 foundByName notEmpty ifTrue:[ |
570 self assert:(foundByName size == 1) message:'multiple components found by name'. |
684 self assert:(foundByName size == 1) message:'multiple components found by name'. |
571 ^ foundByName first. |
685 ^ foundByName first. |
572 ]. |
686 ]. |
573 foundByTitle notEmpty ifTrue:[ |
687 foundByTitle notEmpty ifTrue:[ |
578 self assert:(foundByLabel size == 1) message:'multiple components found by label'. |
692 self assert:(foundByLabel size == 1) message:'multiple components found by label'. |
579 ^ foundByLabel first. |
693 ^ foundByLabel first. |
580 ]. |
694 ]. |
581 ^ component |
695 ^ component |
582 |
696 |
|
697 " |
|
698 self basicNew findComponent:'Klassen' in:(Transcript topView) |
|
699 " |
|
700 |
583 "Created: / 19-07-2019 / 11:36:21 / Claus Gittinger" |
701 "Created: / 19-07-2019 / 11:36:21 / Claus Gittinger" |
584 ! |
702 "Modified (comment): / 23-07-2019 / 09:31:34 / Claus Gittinger" |
585 |
|
586 randomThankYou |
|
587 ^ #( |
|
588 'thank you, for watching' |
|
589 'thank you for watching' |
|
590 'thank you' |
|
591 'have a good day' |
|
592 'have fun' |
|
593 'have fun with expecco' |
|
594 'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: "to sin"' |
|
595 'happy hacking' |
|
596 'happy hacking, I hope you liked what you saw' |
|
597 'hope you liked it' |
|
598 'see you again' |
|
599 'please give feedback, and let us know, if you liked it' |
|
600 'if you have any questions, please contact exept' |
|
601 'if you need more information, please take a look at the wiki' |
|
602 ) atRandom |
|
603 |
|
604 " |
|
605 OperatingSystem speak:'have fun with expecco' |
|
606 OperatingSystem speak:'have fun with expecco, by the way: expecco comes from the latin word: peccare, which means: to sin' |
|
607 OperatingSystem speak:'happy hacking, I hope you liked what you saw' |
|
608 OperatingSystem speak:'please give feedback, and let us know, if you liked it' |
|
609 OperatingSystem speak:'if you have any questions, please contact exept' |
|
610 OperatingSystem speak:'if you need more information, please take a look at the wiki' |
|
611 " |
|
612 |
|
613 "Created: / 19-07-2019 / 21:39:18 / Claus Gittinger" |
|
614 ! |
|
615 |
|
616 tell:message |
|
617 self talking ifTrue:[ |
|
618 OperatingSystem speak:message. |
|
619 ]. |
|
620 |
|
621 "Created: / 19-07-2019 / 14:57:50 / Claus Gittinger" |
|
622 ! ! |
|
623 |
|
624 !ShowMeHowItWorks methodsFor:'helpers - broken'! |
|
625 |
|
626 click:buttonNr atPosition:position |
|
627 "press-release at position" |
|
628 |
|
629 |screen| |
|
630 |
|
631 screen := Screen current. |
|
632 |
|
633 screen setPointerPosition:position. |
|
634 screen flush. |
|
635 self click:buttonNr |
|
636 |
|
637 "Created: / 19-07-2019 / 13:14:51 / Claus Gittinger" |
|
638 ! ! |
703 ! ! |
639 |
704 |
640 !ShowMeHowItWorks methodsFor:'helpers - mouse movement'! |
705 !ShowMeHowItWorks methodsFor:'helpers - mouse movement'! |
641 |
706 |
642 circlePointerAroundComponent:component |
707 circlePointerAroundComponent:aWidgetOrMenuItem |
643 "circle around it a few times" |
708 "circle around it a few times" |
644 |
709 |
645 self circlePointerAroundPosition:(component screenBounds center rounded) |
710 |position| |
|
711 |
|
712 aWidgetOrMenuItem isView ifTrue:[ |
|
713 position := aWidgetOrMenuItem screenBounds center rounded |
|
714 ] ifFalse:[ |
|
715 self halt. |
|
716 ]. |
|
717 self circlePointerAroundScreenPosition:position |
646 |
718 |
647 "Created: / 19-07-2019 / 13:12:35 / Claus Gittinger" |
719 "Created: / 19-07-2019 / 13:12:35 / Claus Gittinger" |
648 ! |
720 "Modified: / 23-07-2019 / 09:38:12 / Claus Gittinger" |
649 |
721 ! |
650 circlePointerAroundPosition:position |
722 |
|
723 circlePointerAroundScreenPosition:position |
651 "circle around it a few times" |
724 "circle around it a few times" |
652 |
725 |
653 |screen stepDelayTime numCircles circlingSpeed radius| |
726 |screen stepDelayTime numCircles circlingSpeed radius| |
654 |
727 |
655 screen := Screen current. |
728 screen := Screen current. |
682 screen setPointerPosition:position rounded. |
755 screen setPointerPosition:position rounded. |
683 screen flush. |
756 screen flush. |
684 Delay waitFor:stepDelayTime. |
757 Delay waitFor:stepDelayTime. |
685 ]. |
758 ]. |
686 |
759 |
687 "Created: / 19-07-2019 / 13:12:40 / Claus Gittinger" |
760 "Created: / 23-07-2019 / 09:37:46 / Claus Gittinger" |
|
761 ! |
|
762 |
|
763 fastMovePointerToScreenPosition:position |
|
764 self movePointerToScreenPosition:position speed:(self pointerMoveSpeedFast). |
|
765 |
|
766 "Created: / 23-07-2019 / 09:36:20 / Claus Gittinger" |
688 ! |
767 ! |
689 |
768 |
690 movePointerToComponent:aWidget |
769 movePointerToComponent:aWidget |
691 "move the mouse to aWidget's center" |
770 "move the mouse to aWidget's center" |
692 |
771 |
693 self movePointerToPosition:(aWidget screenBounds center rounded). |
772 self movePointerToScreenPosition:(aWidget screenBounds center rounded). |
694 |
773 |
695 "Created: / 19-07-2019 / 13:11:33 / Claus Gittinger" |
774 "Created: / 19-07-2019 / 13:11:33 / Claus Gittinger" |
|
775 "Modified: / 23-07-2019 / 09:37:01 / Claus Gittinger" |
696 ! |
776 ! |
697 |
777 |
698 movePointerToComponent:aWidget offset:offset |
778 movePointerToComponent:aWidget offset:offset |
699 "move the mouse to position inside aWidget's" |
779 "move the mouse to position inside aWidget's" |
700 |
780 |
701 self movePointerToPosition:(aWidget screenBounds origin + offset) rounded. |
781 self movePointerToScreenPosition:(aWidget screenBounds origin + offset) rounded. |
702 |
782 |
703 "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger" |
783 "Created: / 19-07-2019 / 16:18:58 / Claus Gittinger" |
704 ! |
784 "Modified: / 23-07-2019 / 09:36:57 / Claus Gittinger" |
705 |
785 ! |
706 movePointerToComponent:aWidget speed:pixelsPerSecond |
786 |
|
787 movePointerToComponent:aWidgetOrMenuItem speed:pixelsPerSecond |
707 "move the mouse to aWidget's center" |
788 "move the mouse to aWidget's center" |
708 |
789 |
709 self movePointerToPosition:(aWidget screenBounds center rounded) speed:pixelsPerSecond. |
790 |position| |
|
791 |
|
792 aWidgetOrMenuItem isView ifTrue:[ |
|
793 position := aWidgetOrMenuItem screenBounds center rounded |
|
794 ] ifFalse:[ |
|
795 self halt. |
|
796 ]. |
|
797 self movePointerToScreenPosition:position speed:pixelsPerSecond. |
710 |
798 |
711 "Created: / 20-07-2019 / 08:12:49 / Claus Gittinger" |
799 "Created: / 20-07-2019 / 08:12:49 / Claus Gittinger" |
712 ! |
800 "Modified: / 23-07-2019 / 09:37:27 / Claus Gittinger" |
713 |
801 ! |
714 movePointerToPosition:newPosition |
802 |
|
803 movePointerToScreenPosition:newPosition |
715 "move the mouse to newPosition" |
804 "move the mouse to newPosition" |
716 |
805 |
717 self movePointerToPosition:newPosition speed:self pointerMoveSpeed |
806 self movePointerToScreenPosition:newPosition speed:(self pointerMoveSpeed) |
718 |
807 |
719 "Created: / 19-07-2019 / 12:57:30 / Claus Gittinger" |
808 "Created: / 23-07-2019 / 09:36:39 / Claus Gittinger" |
720 "Modified: / 20-07-2019 / 08:12:34 / Claus Gittinger" |
809 ! |
721 ! |
810 |
722 |
811 movePointerToScreenPosition:newPosition speed:pixelsPerSecond |
723 movePointerToPosition:newPosition speed:pixelsPerSecond |
812 "move the mouse to newPosition, which is a screen position" |
724 "move the mouse to newPosition" |
|
725 |
813 |
726 |screen distance start numSteps moveTime stepDelayTime delta| |
814 |screen distance start numSteps moveTime stepDelayTime delta| |
727 |
815 |
728 screen := Screen current. |
816 screen := Screen current. |
729 start := screen pointerPosition. |
817 start := screen pointerPosition. |
833 |
922 |
834 screen sendKeyOrButtonEvent:#buttonRelease x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId). |
923 screen sendKeyOrButtonEvent:#buttonRelease x:x y:y keyOrButton:buttonNr state:0 toViewId:(screen rootWindowId). |
835 screen flush. |
924 screen flush. |
836 |
925 |
837 "Created: / 19-07-2019 / 13:53:05 / Claus Gittinger" |
926 "Created: / 19-07-2019 / 13:53:05 / Claus Gittinger" |
|
927 "Modified: / 23-07-2019 / 09:38:38 / Claus Gittinger" |
838 ! ! |
928 ! ! |
839 |
929 |
840 !ShowMeHowItWorks methodsFor:'running'! |
930 !ShowMeHowItWorks methodsFor:'running'! |
841 |
931 |
842 doCommand:op |
932 doCommand:op |
|
933 "execute a single command" |
|
934 |
843 |numArgs sel args method| |
935 |numArgs sel args method| |
844 |
936 |
845 op isArray ifTrue:[ |
937 op isArray ifTrue:[ |
846 op first isArray ifTrue:[ |
938 op first isArray ifTrue:[ |
847 self doStream:op readStream. |
939 self doStream:op readStream. |