267 self debuggingHelpText:true |
267 self debuggingHelpText:true |
268 self debuggingHelpText:false |
268 self debuggingHelpText:false |
269 " |
269 " |
270 |
270 |
271 "Created: / 11-06-2018 / 10:30:24 / Claus Gittinger" |
271 "Created: / 11-06-2018 / 10:30:24 / Claus Gittinger" |
|
272 ! |
|
273 |
|
274 singleton |
|
275 ^ TheOneAndOnlyHelpListener |
|
276 |
|
277 "Created: / 27-02-2019 / 11:06:32 / Claus Gittinger" |
272 ! ! |
278 ! ! |
273 |
279 |
274 !ActiveHelp class methodsFor:'queries'! |
280 !ActiveHelp class methodsFor:'queries'! |
275 |
281 |
276 currentHelpListener |
282 currentHelpListener |
317 |
323 |
318 "Modified: / 10-11-2010 / 12:29:44 / cg" |
324 "Modified: / 10-11-2010 / 12:29:44 / cg" |
319 ! ! |
325 ! ! |
320 |
326 |
321 !ActiveHelp class methodsFor:'start & stop'! |
327 !ActiveHelp class methodsFor:'start & stop'! |
|
328 |
|
329 initiateHelp |
|
330 "determine where the mouse pointer is located, |
|
331 and start showing a tooltip for it. |
|
332 This can be caleld to force update of the tooltip, |
|
333 in case a widget has changed its mind |
|
334 (typically: an undo menu button function might wonna do this, |
|
335 to show changed info)" |
|
336 |
|
337 TheOneAndOnlyHelpListener notNil ifTrue:[ |
|
338 TheOneAndOnlyHelpListener initiateHelp |
|
339 ]. |
|
340 |
|
341 "Created: / 27-02-2019 / 11:08:54 / Claus Gittinger" |
|
342 ! |
322 |
343 |
323 start |
344 start |
324 "start activeHelp for all apps" |
345 "start activeHelp for all apps" |
325 |
346 |
326 TheOneAndOnlyHelpListener notNil ifTrue:[ |
347 TheOneAndOnlyHelpListener notNil ifTrue:[ |
421 "/ Debugging := true |
442 "/ Debugging := true |
422 buttonAndModifierState == 0 ifTrue:[ |
443 buttonAndModifierState == 0 ifTrue:[ |
423 "/ realViewUnderCursor := aView device viewFromPoint:(aView pointerPosition). |
444 "/ realViewUnderCursor := aView device viewFromPoint:(aView pointerPosition). |
424 "/ realP := aView device translatePoint:(x@y) fromView:aView toView:realViewUnderCursor. |
445 "/ realP := aView device translatePoint:(x@y) fromView:aView toView:realViewUnderCursor. |
425 "/ self handleMouseIn:realViewUnderCursor x:realP x y:realP y. |
446 "/ self handleMouseIn:realViewUnderCursor x:realP x y:realP y. |
426 Debugging ifTrue:['motion' infoPrintCR]. |
447 Debugging ifTrue:[('motion %2@%3 in %1' bindWith:aView with:x with:y) infoPrintCR]. |
427 self handleMouseIn:aView x:x y:y. |
448 self handleMouseIn:aView x:x y:y. |
428 ]. |
449 ]. |
429 ^ false |
450 ^ false |
430 |
451 |
431 "Modified: / 11-06-2018 / 10:31:42 / Claus Gittinger" |
452 "Modified: / 27-02-2019 / 15:49:03 / Claus Gittinger" |
432 "Modified (format): / 02-08-2018 / 16:12:45 / Claus Gittinger" |
|
433 ! |
453 ! |
434 |
454 |
435 handleMouseIn:aView x:x y:y |
455 handleMouseIn:aView x:x y:y |
436 "handle motion events - if the mousepointer left the |
456 "handle motion events - if the mousepointer left the |
437 previous helped view, hide the help" |
457 previous helped view, hide the help" |
691 |
711 |
692 aViewsTopView := aView topView. |
712 aViewsTopView := aView topView. |
693 |
713 |
694 UserPreferences current onlyShowTooltipsForActiveWindow ifTrue:[ |
714 UserPreferences current onlyShowTooltipsForActiveWindow ifTrue:[ |
695 Debugging ifTrue:[ |
715 Debugging ifTrue:[ |
696 'TopView:' infoPrint. aViewsTopView infoPrint. |
716 ('TopView: %1 focus: %2 active: %3' |
697 ' focus:' infoPrint. aViewsTopView graphicsDevice focusView infoPrint. |
717 bindWith:aViewsTopView |
698 ' active:' infoPrint. aViewsTopView isActive infoPrintCR. |
718 with:aViewsTopView graphicsDevice focusView |
|
719 with:aViewsTopView isActive) infoPrintCR. |
699 ]. |
720 ]. |
700 aViewsTopView isActive ifFalse:[ |
721 aViewsTopView isActive ifFalse:[ |
701 Debugging ifTrue:[ |
722 Debugging ifTrue:[ |
702 |graphicsDevice focusVw| |
723 |graphicsDevice focusVw| |
703 |
724 |
741 Debugging ifTrue:['not in list of apps I am interested in' infoPrintCR]. |
762 Debugging ifTrue:['not in list of apps I am interested in' infoPrintCR]. |
742 ^ false |
763 ^ false |
743 |
764 |
744 "Created: / 26-10-1997 / 23:28:52 / cg" |
765 "Created: / 26-10-1997 / 23:28:52 / cg" |
745 "Modified: / 08-08-1998 / 13:36:19 / cg" |
766 "Modified: / 08-08-1998 / 13:36:19 / cg" |
746 "Modified (format): / 11-08-2018 / 08:15:40 / Claus Gittinger" |
767 "Modified: / 27-02-2019 / 11:25:58 / Claus Gittinger" |
747 ! |
768 ! |
748 |
769 |
749 targetViewInitiatesHelpViaSensor |
770 targetViewInitiatesHelpViaSensor |
750 "true if the target view is asked to show the help via the sensor; |
771 "true if the target view is asked to show the help via the sensor; |
751 false, if I do it myself synchronously." |
772 false, if I do it myself synchronously." |
780 ex description infoPrintCR. |
801 ex description infoPrintCR. |
781 ex return |
802 ex return |
782 ] do:[ |
803 ] do:[ |
783 self hideHelp. |
804 self hideHelp. |
784 ]. |
805 ]. |
|
806 ! |
|
807 |
|
808 initiateHelp |
|
809 "determine where the mouse pointer is located, |
|
810 and start showing a tooltip for it right now. |
|
811 This can be caleld to force update of the tooltip, |
|
812 in case a widget has changed its mind |
|
813 (typically: an undo menu button function might wonna do this, |
|
814 to show changed info)" |
|
815 |
|
816 |screenPos view| |
|
817 |
|
818 screenPos := Display pointerPosition. |
|
819 Debugging == true ifTrue:[ |
|
820 '----------------' infoPrintCR. |
|
821 'pos: ' infoPrint. screenPos infoPrintCR. |
|
822 ]. |
|
823 view := Display viewFromPoint:screenPos. |
|
824 Debugging == true ifTrue:[ |
|
825 'view: ' infoPrint. view infoPrintCR. |
|
826 ]. |
|
827 view notNil ifTrue:[ |
|
828 self initiateHelpFor:view. |
|
829 ]. |
|
830 |
|
831 "Created: / 27-02-2019 / 11:09:41 / Claus Gittinger" |
|
832 "Modified: / 27-02-2019 / 15:50:18 / Claus Gittinger" |
|
833 ! |
|
834 |
|
835 initiateHelpFor:aView |
|
836 "start showing a tooltip for aView right now. |
|
837 This can be called to force update of the tooltip, |
|
838 in case a widget has changed its mind |
|
839 (typically: an undo menu button function might wonna do this, |
|
840 to show changed info)" |
|
841 |
|
842 |screenPos relativePos| |
|
843 |
|
844 screenPos := Display pointerPosition. |
|
845 Debugging == true ifTrue:[ |
|
846 'pos: ' infoPrint. screenPos infoPrintCR. |
|
847 ]. |
|
848 aView notNil ifTrue:[ |
|
849 relativePos := Display translatePoint:screenPos fromView:nil toView:aView. |
|
850 Debugging == true ifTrue:[ |
|
851 'relativePos: ' infoPrint. relativePos infoPrintCR. |
|
852 ]. |
|
853 self initiateHelpFor:aView at:relativePos |
|
854 ]. |
|
855 |
|
856 "Created: / 27-02-2019 / 13:59:44 / Claus Gittinger" |
|
857 "Modified: / 27-02-2019 / 15:52:07 / Claus Gittinger" |
785 ! |
858 ! |
786 |
859 |
787 initiateHelpFor:aView at:aPointOrNil |
860 initiateHelpFor:aView at:aPointOrNil |
788 "ask aView for helpText, passing x/y coordinates; |
861 "ask aView for helpText, passing x/y coordinates; |
789 start a timeout process to display this helpText after some delay; |
862 start a timeout process to display this helpText after some delay; |
811 re-negotiation of the displayed helpText |
884 re-negotiation of the displayed helpText |
812 (for example in a menu, when the selection changes)" |
885 (for example in a menu, when the selection changes)" |
813 |
886 |
814 |text top app| |
887 |text top app| |
815 |
888 |
|
889 Debugging == true ifTrue:[ |
|
890 'initiate help for: ' infoPrint. aView infoPrintCR. |
|
891 ]. |
816 (self interestedIn:aView) ifFalse:[ |
892 (self interestedIn:aView) ifFalse:[ |
817 ^ self |
893 ^ self |
818 ]. |
894 ]. |
819 |
895 |
820 text := self helpTextFor:aView at:aPointOrNil. |
896 text := self helpTextFor:aView at:aPointOrNil. |