FlyByHelp.st
author Claus Gittinger <cg@exept.de>
Wed, 19 Nov 2014 20:56:18 +0100
changeset 3394 d1f97f49ea4f
parent 3334 d334c9dd9b76
child 3418 a758dd978f99
permissions -rw-r--r--
class: FlyByHelp changed: #initiateHelpFor:at:now:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     1
"
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     2
 COPYRIGHT (c) 2001 by eXept Software AG
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     3
              All Rights Reserved
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     4
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     5
 This software is furnished under a license and may be used
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     6
 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
     7
 inclusion of the above copyright notice.   This software may not
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     9
 other person.  No title to or ownership of the software is
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    10
 hereby transferred.
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    11
"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview2' }"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ActiveHelp subclass:#FlyByHelp
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
    15
	instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess'
3255
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    16
	classVariableNames:'MaxNumberOfLines MaxNumberOfColumns'
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Interface-Help'
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    21
!FlyByHelp class methodsFor:'documentation'!
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    22
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    23
copyright
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    24
"
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    25
 COPYRIGHT (c) 2001 by eXept Software AG
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    26
              All Rights Reserved
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    27
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    28
 This software is furnished under a license and may be used
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    29
 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
    30
 inclusion of the above copyright notice.   This software may not
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    31
 be provided or otherwise made available to, or used by, any
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    32
 other person.  No title to or ownership of the software is
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    33
 hereby transferred.
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    34
"
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    35
!
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    36
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    37
examples
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    38
"
3220
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    39
    UserPreferences current toolTipShapeStyle:nil
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    40
    UserPreferences current toolTipShapeStyle:#cartoon
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    41
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    42
     FlyByHelp isActive
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    43
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    44
     FlyByHelp stop
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    45
     FlyByHelp start
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    46
"
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    47
! !
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    49
!FlyByHelp class methodsFor:'accessing'!
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    50
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    51
currentlyShownView
2846
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    52
    TheOneAndOnlyHelpListener isNil ifTrue:[^ nil].
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    53
    ^ TheOneAndOnlyHelpListener currentlyShownView
2846
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    54
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    55
    "Modified: / 09-06-2010 / 16:35:48 / cg"
3255
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    56
!
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    57
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    58
maxNumberOfColumns
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    59
    ^ MaxNumberOfColumns ? 200
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    60
!
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    61
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    62
maxNumberOfLines
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    63
    ^ MaxNumberOfLines ? 40
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    64
! !
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    65
2684
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    66
!FlyByHelp methodsFor:'defaults'!
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    67
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    68
flyByHelpTimeoutMillis
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    69
    "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
    70
     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
    71
     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
    72
     it takes too long to parse...
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    73
     The returned time is given in ms"
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    74
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    75
    ^ 300
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    76
! !
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    77
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
    78
!FlyByHelp methodsFor:'event handling'!
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
    79
2474
ef24105ee7a2 code cleanup (arg-names)
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
    80
buttonMotion:buttonAndModifierState x:x y:y view:aView
2519
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    81
    aView == currentHelpView ifTrue:[
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    82
        "/ the help-bubble itself
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    83
        ^ false
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    84
    ].
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    85
2518
fc1d2b481b6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
    86
    "/ don't start tooltip, if this view is not active
3243
f78b2a3470eb class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
    87
    "/ 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
    88
    "/ which is always active. Must check after we have determined the view under the pointer
2518
fc1d2b481b6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
    89
    "/ aView topView isActive ifFalse:[^ false].
2477
b009e0b51999 suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents: 2474
diff changeset
    90
2474
ef24105ee7a2 code cleanup (arg-names)
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
    91
    ^ super buttonMotion:buttonAndModifierState x:x y:y view:aView
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
    92
!
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
    93
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
    94
buttonPress:button x:x y:y view:aView
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    95
    |prevView|
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    96
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    97
    "/ hideHelp nils the currentView
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    98
    "/ 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
    99
    "/ until the mouse really leaves the view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   100
    "/ let's call this the "do-not-show-in-this-view mode"
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   101
    prevView := currentView.
2978
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   102
    self hideHelp.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   103
    currentView := prevView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   104
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   105
    ^ false
2978
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   106
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
   107
    "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
   108
!
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   109
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   110
keyPress:key x:x y:y view:aView
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   111
    <resource: #keyboard (#Escape)>
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   112
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   113
    |prevView|
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   114
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   115
    currentHelpView notNil ifTrue:[
2925
352825e1163c changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2920
diff changeset
   116
        key == $§ ifTrue:[
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   117
            "/ generate a line suitable for the resources file (a null translation)
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   118
            "/ into the clipboard; makes it easy to add missing translations to a .rs file,
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   119
            "/ by pressing paragrapj whenever you see an untranslated helptext
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   120
            aView setClipboardText:(lastHelpText storeString , '    ' , lastHelpText storeString).
2612
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   121
            self hideHelp.
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   122
            ^ true
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   123
        ].
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   124
        key == #Escape ifTrue:[
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   125
            prevView := currentView.
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   126
            self hideHelp.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   127
            currentView := prevView.
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   128
            ^ true
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   129
        ].
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   130
        (#('Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   131
            "/ do not close on those...
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   132
            ^ false
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   133
        ].
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   134
    ].
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   135
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   136
    "/ hideHelp nils the currentView
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   137
    "/ 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
   138
    "/ until the mouse really leaves the view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   139
    "/ let's call this the "do-not-show-in-this-view mode"
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   140
    prevView := currentView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   141
    self hideHelpIgnoringErrors.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   142
    currentView := prevView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   143
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   144
    ^ false
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   145
    "/ ^ 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
   146
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   147
    "Modified (format): / 25-12-2011 / 10:25:23 / cg"
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   148
!
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   149
2521
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   150
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
   151
    currentHelpView notNil ifTrue:[
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   152
        self handleMouseIn:aView x:x y:y.
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   153
    ].
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   154
    ^ false
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   155
!
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   156
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   157
pointerLeave:state view:aView
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   158
    aView == currentHelpView ifTrue:[^ true].
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   159
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   160
    "/ clear the do-not-show-in-this-view mode (see keyPress)
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   161
"/     (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil].
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   162
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   163
    ^ super pointerLeave:state view:aView
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   164
! !
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   165
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   166
!FlyByHelp methodsFor:'help texts'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
helpTextFromModel:aModel view:aView at:aPointOrNil 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "helper: ask aModel for its helpText."
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    |text|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    aPointOrNil notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
        (aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
            text := aModel flyByHelpTextFor:aView at:aPointOrNil.
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   176
            text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   179
    (aModel respondsTo:#flyByHelpTextFor:) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   180
        text := aModel flyByHelpTextFor:aView.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   181
        text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   183
    ^ nil
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
helpTextFromView:aView at:aPointOrNil 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    "helper: ask aView for its helpText."
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   189
    |text key app|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    aPointOrNil notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        (aView respondsTo:#flyByHelpTextAt:) ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
            text := aView flyByHelpTextAt:aPointOrNil.
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   194
            text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   197
    (aView respondsTo:#flyByHelpText) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   198
        text := aView flyByHelpText.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   199
        text notNil ifTrue:[^ text].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   200
    ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   201
    (aView respondsTo:#helpKey) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   202
        key := aView helpKey.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   203
        key notNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   204
            app := aView application.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   205
            app isNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   206
                app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   207
            ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   208
            app notNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   209
                ^ app flyByHelpTextForKey:key
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   210
            ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   211
            ^ aView resources string:key
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   214
    ^ nil.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   215
! !
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   216
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   217
!FlyByHelp methodsFor:'private'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
hideIfPointerLeft:aView
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "hide help, if the pointer is not in aView"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    |whereOnScreen|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    currentFrame notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
        whereOnScreen := aView graphicsDevice pointerPosition.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        (currentFrame notNil
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
        and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
            self hideHelp.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    "Modified: 28.5.1996 / 20:18:28 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
initiateHelpFor:aView at:aPointOrNil now:showItNow
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "ask aView for helpText, passing x/y coordinates;
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
     start a timeout process to display this helpText after some delay;
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
     Normally used internally, but can also be used by widgets to force 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
     re-negotiation of the displayed helpText 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
     (for example in a menu, when the selection changes)"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   243
    |text delayTime now|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    (self interestedIn:aView) ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
        ^ self
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   249
    now := Timestamp now.
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   250
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   251
    "/ 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
   252
    "/ 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
   253
    [
2826
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   254
        Error handle:[:ex |
3394
d1f97f49ea4f class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3334
diff changeset
   255
            ('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR.
d1f97f49ea4f class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3334
diff changeset
   256
            ex suspendedContext fullPrintAllOn:Transcript.
2872
ea7e6fe01727 comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   257
            "/ self halt.
2826
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   258
        ] do:[
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   259
            text := self helpTextFor:aView at:aPointOrNil.
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   260
        ].
2684
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   261
    ] valueWithWatchDog:[ ^ self ] afterMilliseconds:(self flyByHelpTimeoutMillis).
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   262
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    lastHelpText = text ifTrue:[
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   264
        lastHelpWidget == aView ifTrue:[ 
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   265
            self toolTipFollowsMouse ifFalse:[
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   266
                ^ self
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   267
            ]
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   268
        ]
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    text size > 0 ifTrue:[
2778
8b91cf06a145 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2777
diff changeset
   272
        (showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
            self stopHelpDisplayProcess.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   274
            showProcess := 
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   275
                [
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   276
                    Delay waitForSeconds:delayTime.
2774
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   277
                    [
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   278
                        aView device anyButtonPressed ifFalse:[
2777
4cdef981fdb3 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   279
                            showProcess := nil.
2774
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   280
                            self showHelp:text for:aView
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   281
                        ]
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   282
                    ] ensure:[
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   283
                        showProcess := nil.
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   284
                    ]
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   285
                ] forkAt:(Processor userSchedulingPriority + 1).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
        ] ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
            self showHelp:text for:aView
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
        ]
1542
f63515aab510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1540
diff changeset
   289
    ] ifFalse:[
f63515aab510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1540
diff changeset
   290
        self hideHelp
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    ].
2872
ea7e6fe01727 comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   292
2901
fed697afcef8 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   293
    "Modified: / 22-03-2011 / 19:10:28 / cg"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
! !
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   296
!FlyByHelp methodsFor:'queries'!
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   297
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   298
currentlyShownView
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   299
    ^ currentHelpView
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   300
!
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   301
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   302
toolTipFollowsMouse
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   303
    ^ false
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   304
! !
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   305
1768
7011c938442e method category rename
Claus Gittinger <cg@exept.de>
parents: 1677
diff changeset
   306
!FlyByHelp methodsFor:'show & hide help'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
3248
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   308
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   309
    applicationOrNil notNil ifTrue:[
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   310
        ^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   311
    ].
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   312
    ^ ActiveHelpView for:helpText onDevice:aDevice.
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   313
!
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   314
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
hideHelp
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    "hide the help text"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
    |p|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   320
    "/ lastHelpText := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    self stopHelpDisplayProcess.
3258
b0c9d06f22ef class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3257
diff changeset
   322
    lastHelpText := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    currentHelpView notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
        [
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   326
            currentHelpView notNil ifTrue:[
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   327
                currentHelpView unmap.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   328
                currentHelpView destroy.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   329
                currentHelpView := nil.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   330
                currentView := nil.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   331
            ]
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
        ] valueUninterruptably
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
    currentFrame := nil.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   335
    (p := closeProcess) notNil ifTrue:[
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   336
        closeProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    ]
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    "Modified: 28.6.1997 / 14:03:50 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
showHelp:aHelpText for:view
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    "show the help text for aView"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   346
    |wg applicationOrNil org p v dev helpTextShown textLines
3334
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   347
     helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   348
     showTime|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
2781
31725cdfbe43 leftover print
Claus Gittinger <cg@exept.de>
parents: 2780
diff changeset
   350
    "/ thisContext fullPrintAllOn:Transcript.
2651
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   351
    (wg := view windowGroup) notNil ifTrue:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   352
        wg isInModalLoop ifTrue:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   353
            wg isModal ifFalse:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   354
                ^ self
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   355
            ].
2628
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   356
        ].
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   357
    ].
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   358
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    view == currentView ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
        lastHelpText = aHelpText ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
            ^ self
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
        ]
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    ].
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   364
    lastHelpWidget := view.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    lastHelpText := aHelpText.
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   367
    helpTextShown := aHelpText.
3257
382b74692cfc class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3255
diff changeset
   368
    "/ the text originator must already have generated CRs;
382b74692cfc class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3255
diff changeset
   369
    "/ no longer done here (otherwise, we could not generate tooltips with windows filenames in it)
382b74692cfc class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3255
diff changeset
   370
    textLines := helpTextShown "withCRs" asCollectionOfLines asStringCollection.
3255
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
   371
    textLines size > (self class maxNumberOfLines) ifTrue:[
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
   372
        textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...'
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   373
    ].
3255
358f5696bc0d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
   374
    textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)].
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   375
    helpTextShown := textLines asString.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   377
    (p := closeProcess) notNil ifTrue:[
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   378
        closeProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    currentHelpView notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
        self hideHelp
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    org := view originRelativeTo:nil.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    currentFrame := org extent:view extent.
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   387
    org := org + (view extent // 2).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
1677
dc49ab70b762 open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents: 1657
diff changeset
   389
    dev := view graphicsDevice.
3248
d72c8e4f7684 more control over the shape style
Claus Gittinger <cg@exept.de>
parents: 3247
diff changeset
   390
    wg notNil ifTrue:[ applicationOrNil := wg application ].
3251
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   391
    v := self activeHelpViewForApplication:applicationOrNil text:helpTextShown onDevice:dev.
afc7d588b25b handle key press and close help.
Claus Gittinger <cg@exept.de>
parents: 3248
diff changeset
   392
    v perform:#controllingHelpListener: with:self ifNotUnderstood:[].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   394
    helpViewWidth := v width.
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   395
    helpViewHeight := v height.
1677
dc49ab70b762 open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents: 1657
diff changeset
   396
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   397
    org := dev pointerPosition + (0@18"24").
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   398
    monitorBounds := dev monitorBoundsAt:org.
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   399
    usableWidth := monitorBounds width - 2.
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   400
    usableHeight := dev usableHeightAt:org.
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   401
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   402
    helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)].    
3247
768269b26ad3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3243
diff changeset
   403
    helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)].    
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   404
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   405
    (org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   406
        org := ((monitorBounds left + usableWidth - helpViewWidth) @ org y).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    ].
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   408
    (org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   409
        org := org x @ (monitorBounds top + usableHeight - helpViewHeight).
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
    v origin:org.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    v realize.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    v enableButtonMotionEvents.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    v enableMotionEvents.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
    currentHelpView := v.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   417
    currentView := view.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
3334
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   419
    showTime := self showTime.
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   420
    (showTime notNil and:[showTime > 0]) ifTrue:[
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   421
        closeProcess := [
1546
1af738601dae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   422
                [
3334
d334c9dd9b76 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3321
diff changeset
   423
                    (Delay forSeconds:showTime) wait.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   424
                    [
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   425
                        |v|
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   426
                        (v := currentHelpView) notNil ifTrue:[
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   427
                            currentHelpView := nil.
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   428
                            v unmap.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   429
                            v destroy.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   430
                        ]
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   431
                    ] valueUninterruptably
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   432
                ] ifCurtailed:[
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   433
                    closeProcess := nil.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   434
                ].
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   435
            ] newProcess.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   436
        closeProcess priority:(Processor userSchedulingPriority + 1).
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   437
        closeProcess resume.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   438
    ].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
1963
fb6663696d20 removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   440
    "Modified: / 31-08-1995 / 19:20:45 / claus"
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   441
    "Modified: / 16-07-2010 / 14:33:13 / cg"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
stopHelpDisplayProcess
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
    |p|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   447
    (p := showProcess) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   448
        showProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
    "Created: 28.6.1997 / 14:03:17 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
! !
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
!FlyByHelp class methodsFor:'documentation'!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   457
version
3394
d1f97f49ea4f class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3334
diff changeset
   458
    ^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.68 2014-11-19 19:56:18 cg Exp $'
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   459
!
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   460
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   461
version_CVS
3394
d1f97f49ea4f class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3334
diff changeset
   462
    ^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.68 2014-11-19 19:56:18 cg Exp $'
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
! !
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   464