FlyByHelp.st
author Claus Gittinger <cg@exept.de>
Wed, 06 Jun 2018 17:37:31 +0200
changeset 4110 1a4cf666aafe
parent 4082 f2ffa50dcf0b
child 4111 f42780e51cc1
permissions -rw-r--r--
#UI_ENHANCEMENT by cg class: FlyByHelp comment/format in: #toolTipFollowsMouse changed: #helpTextFromView:at: #initiateHelpFor:at:now: debugging missing tooltips
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
     1
"{ Encoding: utf8 }"
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
     2
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     3
"
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     4
 COPYRIGHT (c) 2001 by eXept Software AG
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     5
              All Rights Reserved
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     6
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     7
 This software is furnished under a license and may be used
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     8
 only in accordance with the terms of that license and with the
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    10
 be provided or otherwise made available to, or used by, any
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    11
 other person.  No title to or ownership of the software is
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    12
 hereby transferred.
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    13
"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libview2' }"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
3656
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
    16
"{ NameSpace: Smalltalk }"
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
    17
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
ActiveHelp subclass:#FlyByHelp
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
    19
	instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess'
3255
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    20
	classVariableNames:'MaxNumberOfLines MaxNumberOfColumns'
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Interface-Help'
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    25
!FlyByHelp class methodsFor:'documentation'!
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    26
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    27
copyright
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    28
"
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    29
 COPYRIGHT (c) 2001 by eXept Software AG
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    30
              All Rights Reserved
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    31
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    32
 This software is furnished under a license and may be used
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    33
 only in accordance with the terms of that license and with the
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    35
 be provided or otherwise made available to, or used by, any
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    36
 other person.  No title to or ownership of the software is
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    37
 hereby transferred.
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    38
"
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    39
!
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    40
4055
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    41
documentation
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    42
"
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    43
    an instance of me is used to provide tooltips 
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    44
    (sigh: smalltalk was ahead of its time in the early 90's:
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    45
     initially called 'activeHelp', then renamed to 'flyByHelp' 
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    46
     and now commonly known as tooltip).
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    47
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    48
    I will watch the mouse movements via an event hook, and determine
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    49
    where the mouse pointer is. Then ask the underlying view about its
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    50
    helpText and display it in a little floating popup view.
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    51
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    52
    The hool is installed via:
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    53
     FlyByHelp start
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    54
    and possibly deactivated/uninstalled via:
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    55
     FlyByHelp stop
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    56
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    57
    There can be only one FlyByHelp at any time - the start/stop methods
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    58
    assure that.
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    59
"
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    60
!
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
    61
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    62
examples
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    63
"
3220
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    64
    UserPreferences current toolTipShapeStyle:nil
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    65
    UserPreferences current toolTipShapeStyle:#cartoon
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    66
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    67
     FlyByHelp isActive
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    68
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    69
     FlyByHelp stop
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    70
     FlyByHelp start
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    71
"
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    72
! !
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    74
!FlyByHelp class methodsFor:'accessing'!
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    75
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    76
currentlyShownView
2846
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    77
    TheOneAndOnlyHelpListener isNil ifTrue:[^ nil].
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    78
    ^ TheOneAndOnlyHelpListener currentlyShownView
2846
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    79
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    80
    "Modified: / 09-06-2010 / 16:35:48 / cg"
3255
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    81
!
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    82
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    83
maxNumberOfColumns
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    84
    ^ MaxNumberOfColumns ? 200
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    85
!
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    86
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    87
maxNumberOfLines
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    88
    ^ MaxNumberOfLines ? 40
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    89
! !
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    90
2684
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    91
!FlyByHelp methodsFor:'defaults'!
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    92
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    93
flyByHelpTimeoutMillis
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    94
    "abort flyby help text generation, if no text can be generated within that
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    95
     time delta. This is used to abort long-lasting parsing/scanning/analysis in
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    96
     large methods when the mouse is moved over some syntactic constructs, and
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    97
     it takes too long to parse...
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    98
     The returned time is given in ms"
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    99
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   100
    ^ 300
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   101
! !
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   102
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   103
!FlyByHelp methodsFor:'event handling'!
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   104
2474
ef24105ee7a2 code cleanup (arg-names)
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   105
buttonMotion:buttonAndModifierState x:x y:y view:aView
2519
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   106
    aView == currentHelpView ifTrue:[
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   107
        "/ the help-bubble itself
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   108
        ^ false
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   109
    ].
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
   110
4055
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
   111
    "/ don't start tooltip, if this view is not active.
92c2d38634c1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4048
diff changeset
   112
    "/ The following line does not work, because motion events are reported for the current focus-view,
3321
e749388a10b8 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 3293
diff changeset
   113
    "/ which is always active. Must check after we have determined the view under the pointer
3675
c7ba11759026 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3656
diff changeset
   114
    "/      aView topView isActive ifFalse:[^ false].
2477
b009e0b51999 suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents: 2474
diff changeset
   115
2474
ef24105ee7a2 code cleanup (arg-names)
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
   116
    ^ super buttonMotion:buttonAndModifierState x:x y:y view:aView
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   117
!
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   118
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   119
buttonPress:button x:x y:y view:aView
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   120
    |prevView|
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   121
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   122
    "/ hideHelp nils the currentView
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   123
    "/ we restore it, so the tooltip is not shown again for this view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   124
    "/ until the mouse really leaves the view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   125
    "/ let's call this the "do-not-show-in-this-view mode"
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   126
    prevView := currentView.
2978
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   127
    self hideHelp.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   128
    currentView := prevView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   129
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   130
    ^ false
2978
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   131
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   132
    "Modified: / 23-12-2011 / 20:37:28 / cg"
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   133
!
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   134
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   135
keyPress:key x:x y:y view:aView
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   136
    <resource: #keyboard (#Escape)>
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   137
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   138
    |prevView|
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   139
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   140
    currentHelpView notNil ifTrue:[
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   141
        key == $§ ifTrue:[
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   142
            "/ generate a line suitable for the resources file (a null translation)
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   143
            "/ into the clipboard; makes it easy to add missing translations to a .rs file,
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   144
            "/ by pressing paragraph whenever you see an untranslated helptext
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   145
            aView setClipboardText:(lastHelpText storeString , '    ' , lastHelpText storeString).
2612
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   146
            self hideHelp.
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   147
            ^ true
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   148
        ].
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   149
        key == #Escape ifTrue:[
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   150
            prevView := currentView.
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   151
            self hideHelp.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   152
            currentView := prevView.
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   153
            ^ true
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   154
        ].
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   155
        (#('Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   156
            "/ do not close on those...
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   157
            ^ false
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   158
        ].
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   159
    ].
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   160
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   161
    "/ hideHelp nils the currentView
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   162
    "/ we restore it, so the tooltip is not shown again for this view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   163
    "/ until the mouse really leaves the view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   164
    "/ let's call this the "do-not-show-in-this-view mode"
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   165
    prevView := currentView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   166
    self hideHelpIgnoringErrors.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   167
    currentView := prevView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   168
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   169
    ^ false
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   170
    "/ ^ super keyPress:key x:x y:y view:aView
2884
7d37f5a0719e changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2878
diff changeset
   171
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   172
    "Modified (format): / 25-12-2011 / 10:25:23 / cg"
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   173
    "Modified (format): / 16-04-2018 / 16:53:15 / stefan"
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   174
!
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   175
2521
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   176
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   177
    currentHelpView notNil ifTrue:[
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   178
        self handleMouseIn:aView x:x y:y.
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   179
    ].
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   180
    ^ false
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   181
!
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   182
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   183
pointerLeave:state view:aView
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   184
    aView == currentHelpView ifTrue:[^ true].
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   185
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   186
    "/ clear the do-not-show-in-this-view mode (see keyPress)
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   187
"/     (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil].
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   188
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   189
    ^ super pointerLeave:state view:aView
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   190
! !
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   191
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   192
!FlyByHelp methodsFor:'help texts'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
helpTextFromModel:aModel view:aView at:aPointOrNil 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    "helper: ask aModel for its helpText."
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    |text|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   199
    (aPointOrNil notNil and:[aModel respondsTo:#helpTextFor:at:]) ifTrue:[
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   200
        text := aModel helpTextFor:aView at:aPointOrNil.
4040
1d540ba7a1d1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3959
diff changeset
   201
        text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    ].
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   203
    (aModel respondsTo:#helpTextFor:) ifTrue:[
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   204
        text := aModel helpTextFor:aView.
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   205
        text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   207
    ^ nil
4040
1d540ba7a1d1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3959
diff changeset
   208
1d540ba7a1d1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3959
diff changeset
   209
    "Modified: / 09-01-2018 / 17:35:26 / stefan"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
helpTextFromView:aView at:aPointOrNil 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    "helper: ask aView for its helpText."
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   215
    |text key app|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   217
    (aPointOrNil notNil and:[aView respondsTo:#helpTextAt:]) ifTrue:[
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   218
(aView isKindOf:MenuPanel) ifTrue:[self halt].
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   219
        text := aView helpTextAt:aPointOrNil.
4040
1d540ba7a1d1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3959
diff changeset
   220
        text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    ].
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   222
    (aView respondsTo:#helpText) ifTrue:[
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   223
        text := aView helpText.
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   224
        text notNil ifTrue:[^ text].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   225
    ].
3804
23207b26bfee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3803
diff changeset
   226
    "/ to be enabled in next release...
23207b26bfee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3803
diff changeset
   227
"/    (aView superView notNil
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   228
"/    and:[aView superView respondsTo:#helpTextFor:]) ifTrue:[
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   229
"/        text := aView superView helpTextFor:aView.
3804
23207b26bfee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3803
diff changeset
   230
"/        text notNil ifTrue:[^ text].
23207b26bfee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3803
diff changeset
   231
"/    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   232
    (aView respondsTo:#helpKey) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   233
        key := aView helpKey.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   234
        key notNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   235
            app := aView application.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   236
            app isNil ifTrue:[
3763
72a6db06eee5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3681
diff changeset
   237
                "/ special case for oldStyle Dialog subclasses.
4048
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   238
                aView topView helpSpec notNil ifTrue:[
eceffed47e1c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4040
diff changeset
   239
                    text := aView topView helpSpec at:key ifAbsent:nil.
3763
72a6db06eee5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3681
diff changeset
   240
                    text notNil ifTrue:[
72a6db06eee5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3681
diff changeset
   241
                        ^ aView topView resources stringWithCRs:text.
72a6db06eee5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3681
diff changeset
   242
                    ].    
72a6db06eee5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3681
diff changeset
   243
                ].    
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   244
                app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   245
            ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   246
            app notNil ifTrue:[
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   247
                ^ "text :=" app helpTextForKey:key.
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   248
                text notNil ifTrue:[^ text].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   249
            ].
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   250
            ^ "text :=" aView resources string:key.
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   251
            (text notNil and:[text ~= key]) ifTrue:[
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   252
                ^ text
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   253
            ]    
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   256
    ^ nil.
4040
1d540ba7a1d1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3959
diff changeset
   257
1d540ba7a1d1 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3959
diff changeset
   258
    "Modified: / 09-01-2018 / 17:38:42 / stefan"
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   259
    "Modified: / 06-06-2018 / 17:00:05 / Claus Gittinger"
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   260
! !
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   261
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   262
!FlyByHelp methodsFor:'private'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
hideIfPointerLeft:aView
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "hide help, if the pointer is not in aView"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    |whereOnScreen|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    currentFrame notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
        whereOnScreen := aView graphicsDevice pointerPosition.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
        (currentFrame notNil
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
        and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
            self hideHelp.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   278
    "Modified: / 28-05-1996 / 20:18:28 / cg"
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   279
    "Modified: / 16-04-2018 / 16:59:48 / stefan"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
initiateHelpFor:aView at:aPointOrNil now:showItNow
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "ask aView for helpText, passing x/y coordinates;
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
     start a timeout process to display this helpText after some delay;
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
     Normally used internally, but can also be used by widgets to force 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
     re-negotiation of the displayed helpText 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
     (for example in a menu, when the selection changes)"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   289
    |text delayTime|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    (self interestedIn:aView) ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
        ^ self
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   295
    "/ do not allow for more than 200 ms to be spent in the
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   296
    "/ helpText gatherer (the codeView parses the code for the variable under the cursor)
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   297
    [
2826
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   298
        Error handle:[:ex |
3394
d1f97f49ea4f class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3334
diff changeset
   299
            ('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR.
3675
c7ba11759026 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3656
diff changeset
   300
            Transcript showCR:'-------------------------'.
3394
d1f97f49ea4f class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3334
diff changeset
   301
            ex suspendedContext fullPrintAllOn:Transcript.
2872
ea7e6fe01727 comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   302
            "/ self halt.
2826
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   303
        ] do:[
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   304
            text := self helpTextFor:aView at:aPointOrNil.
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   305
        ].
3656
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   306
    ] valueWithWatchDog:[ 
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   307
        'FlyByhelp [info]: flyBy text generation took too long' infoPrintCR.
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   308
        ^ self 
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   309
    ] afterMilliseconds:(self flyByHelpTimeoutMillis).
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   310
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   311
    false ifTrue:[
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   312
        (text notNil and:[text isEmpty]) ifTrue:[ 
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   313
            Logger warning:('empty help from: ',aView class printString)
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   314
        ] ifFalse:[
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   315
            text isEmptyOrNil ifTrue:[ 
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   316
                Logger warning:('no help from: ',aView class printString)
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   317
            ].
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   318
        ].
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   319
    ].
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   320
    
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   321
    (lastHelpText = text and:[lastHelpWidget == aView]) ifTrue:[ 
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   322
        self toolTipFollowsMouse ifFalse:[
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   323
            ^ self
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   324
        ]
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   327
    ((text size > 0) or:[text notNil and:[text isString not]]) ifTrue:[
2778
8b91cf06a145 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2777
diff changeset
   328
        (showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
            self stopHelpDisplayProcess.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   330
            showProcess := 
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   331
                [
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   332
                    Delay waitForSeconds:delayTime.
2774
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   333
                    [
3766
4d3c0206456a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3763
diff changeset
   334
                        aView device notNil ifTrue:[    
4d3c0206456a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3763
diff changeset
   335
                            aView device anyButtonPressed ifFalse:[
4d3c0206456a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3763
diff changeset
   336
                                showProcess := nil.
4d3c0206456a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3763
diff changeset
   337
                                self showHelp:text for:aView
4d3c0206456a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3763
diff changeset
   338
                            ]
4d3c0206456a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3763
diff changeset
   339
                        ].
2774
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   340
                    ] ensure:[
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   341
                        showProcess := nil.
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   342
                    ]
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   343
                ] forkAt:(Processor userSchedulingPriority + 1).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
        ] ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
            self showHelp:text for:aView
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
        ]
1542
f63515aab510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1540
diff changeset
   347
    ] ifFalse:[
f63515aab510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1540
diff changeset
   348
        self hideHelp
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    ].
2872
ea7e6fe01727 comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   350
2901
fed697afcef8 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   351
    "Modified: / 22-03-2011 / 19:10:28 / cg"
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   352
    "Modified: / 16-04-2018 / 12:20:33 / stefan"
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   353
    "Modified: / 06-06-2018 / 17:19:26 / Claus Gittinger"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
! !
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   356
!FlyByHelp methodsFor:'queries'!
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   357
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   358
currentlyShownView
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   359
    ^ currentHelpView
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   360
!
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   361
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   362
toolTipFollowsMouse
3675
c7ba11759026 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3656
diff changeset
   363
    "if true, the tooltip-window moves with the pointer
c7ba11759026 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3656
diff changeset
   364
     so that it stays away from (does not cover) the mouse pointer"
c7ba11759026 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3656
diff changeset
   365
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   366
    ^ false
4110
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   367
1a4cf666aafe #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4082
diff changeset
   368
    "Modified: / 06-06-2018 / 17:37:19 / Claus Gittinger"
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   369
! !
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   370
1768
7011c938442e method category rename
Claus Gittinger <cg@exept.de>
parents: 1677
diff changeset
   371
!FlyByHelp methodsFor:'show & hide help'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
3248
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   373
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   374
    applicationOrNil notNil ifTrue:[
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   375
        ^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   376
    ].
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   377
    ^ ActiveHelpView for:helpText onDevice:aDevice.
3656
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   378
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   379
    "
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   380
     (ActiveHelpView for:'Hello' onDevice:Display) open
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   381
    "
3248
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   382
!
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   383
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
hideHelp
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    "hide the help text"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    |p|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   389
    "/ lastHelpText := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    self stopHelpDisplayProcess.
3258
b0c9d06f22ef class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3257
diff changeset
   391
    lastHelpText := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    currentHelpView notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
        [
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   395
            currentHelpView notNil ifTrue:[
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   396
                currentHelpView destroy.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   397
                currentHelpView := nil.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   398
                currentView := nil.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   399
            ]
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
        ] valueUninterruptably
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    currentFrame := nil.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   403
    (p := closeProcess) notNil ifTrue:[
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   404
        closeProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    ]
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   408
    "Modified: / 28-06-1997 / 14:03:50 / cg"
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   409
    "Modified: / 16-04-2018 / 16:51:01 / stefan"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
showHelp:aHelpText for:view
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    "show the help text for aView"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
3786
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   415
    |wg applicationOrNil org p v device helpTextShown textLines
3334
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   416
     helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   417
     showTime cursorView pos|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
2781
31725cdfbe43 leftover print
Claus Gittinger <cg@exept.de>
parents: 2780
diff changeset
   419
    "/ thisContext fullPrintAllOn:Transcript.
2651
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   420
    (wg := view windowGroup) notNil ifTrue:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   421
        wg isInModalLoop ifTrue:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   422
            wg isModal ifFalse:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   423
                ^ self
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   424
            ].
2628
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   425
        ].
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   426
    ].
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   427
3786
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   428
    device := view graphicsDevice.
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   429
3418
a758dd978f99 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   430
    "/ mouse still over that view?
3786
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   431
    cursorView := device viewFromPoint:(device pointerPosition).
3418
a758dd978f99 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   432
    cursorView ~~ view ifTrue:[
a758dd978f99 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   433
        Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ].
a758dd978f99 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   434
        ^ self
a758dd978f99 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   435
    ].
a758dd978f99 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
   436
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   437
    (view == currentView and:[lastHelpText = aHelpText]) ifTrue:[
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   438
        ^ self
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
    ].
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   440
    lastHelpWidget := view.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
    lastHelpText := aHelpText.
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   442
    helpTextShown := aHelpText.
3257
382b74692cfc class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3255
diff changeset
   443
    "/ the text originator must already have generated CRs;
382b74692cfc class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3255
diff changeset
   444
    "/ no longer done here (otherwise, we could not generate tooltips with windows filenames in it)
3681
c56b665d08a7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   445
    textLines := helpTextShown isStringCollection 
c56b665d08a7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3675
diff changeset
   446
                    ifTrue:[helpTextShown]
3767
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   447
                    ifFalse:[ 
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   448
                        helpTextShown isString 
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   449
                            ifTrue:[helpTextShown "withCRs" asCollectionOfLines asStringCollection]
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   450
                            ifFalse:[nil]].
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   451
    textLines notNil ifTrue:[
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   452
        textLines size > (self class maxNumberOfLines) ifTrue:[
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   453
            textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...'
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   454
        ].
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   455
        textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)].
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   456
        helpTextShown := textLines asString.
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   457
    ].
3767
d88339439fb4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 3766
diff changeset
   458
    
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   459
    (p := closeProcess) notNil ifTrue:[
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   460
        closeProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    currentHelpView notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
        self hideHelp
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
3770
690e17824673 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3769
diff changeset
   467
    "/ Transcript showCR:helpTextShown storeString.
3769
09e08477457d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3767
diff changeset
   468
    helpTextShown isEmptyOrNil ifTrue:[^ self].
09e08477457d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3767
diff changeset
   469
    
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
    org := view originRelativeTo:nil.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
    currentFrame := org extent:view extent.
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   472
    org := org + (view extent // 2).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
3248
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   474
    wg notNil ifTrue:[ applicationOrNil := wg application ].
3786
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   475
    v := self activeHelpViewForApplication:applicationOrNil text:helpTextShown onDevice:device.
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   476
    v perform:#controllingHelpListener: with:self ifNotUnderstood:[].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   478
    helpViewWidth := v width.
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   479
    helpViewHeight := v height.
1677
dc49ab70b762 open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents: 1657
diff changeset
   480
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   481
    "https://expeccoalm.exept.de/D226383: keep the help window away from the pointer under any circumstances
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   482
     (especially when the window touches the bottom or the right edge of the screen).
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   483
     When the pointer is no longer in the current window, the help window is closed!!"
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   484
    pos := device pointerPosition.
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   485
    org := pos + (10@18).
3786
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   486
    monitorBounds := device monitorBoundsAt:org.
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   487
    usableWidth := monitorBounds width - 2.
3786
c628a30083c3 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3770
diff changeset
   488
    usableHeight := device usableHeightAt:org.
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   489
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   490
    helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)].    
3247
768269b26ad3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3243
diff changeset
   491
    helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)].    
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   492
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   493
    (org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   494
        org x:(monitorBounds left + usableWidth - helpViewWidth).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
    ].
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   496
    (org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   497
        org y:(monitorBounds top + usableHeight - helpViewHeight).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
    ].
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   499
    ((org extent:v extent) containsPoint:pos) ifTrue:[
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   500
        "pointer would be in the help window (see comment above).
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   501
         Help window is at the lower right edge. Move it to the left of the pointer"
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   502
        org x:(pos x - helpViewWidth - 20).
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   503
    ].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
    v origin:org.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
    v realize.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
    currentHelpView := v.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   507
    currentView := view.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
3334
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   509
    showTime := self showTime.
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   510
    (showTime > 0) ifTrue:[
3959
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   511
        p :=
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   512
            [
1546
1af738601dae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   513
                [
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   514
                    Delay waitForSeconds:showTime.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   515
                    [
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   516
                        |v|
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   517
                        (v := currentHelpView) notNil ifTrue:[
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   518
                            currentHelpView := nil.
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   519
                            v destroy.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   520
                        ]
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   521
                    ] valueUninterruptably
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   522
                ] ifCurtailed:[
3959
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   523
                    (p == closeProcess) ifTrue:[ closeProcess := nil ].
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   524
                ].
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   525
            ] newProcess.
3959
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   526
        p priority:(Processor userSchedulingPriority + 1).
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   527
        closeProcess := p.
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   528
        p resume.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   529
    ].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
1963
fb6663696d20 removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   531
    "Modified: / 31-08-1995 / 19:20:45 / claus"
3959
63a594820146 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   532
    "Modified: / 06-06-2017 / 15:06:41 / cg"
4082
f2ffa50dcf0b #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
   533
    "Modified (format): / 16-04-2018 / 17:29:10 / stefan"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
stopHelpDisplayProcess
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
    |p|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   539
    (p := showProcess) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   540
        showProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    "Created: 28.6.1997 / 14:03:17 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
! !
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
!FlyByHelp class methodsFor:'documentation'!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   549
version
3656
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   550
    ^ '$Header$'
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   551
!
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   552
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   553
version_CVS
3656
de582c82fa70 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3418
diff changeset
   554
    ^ '$Header$'
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
! !
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   556