#UI_ENHANCEMENT by cg
class: FlyByHelp
hide help if mouse is moved
(behaviour as in OS)
changed:
#hideIfPointerLeft:
#showHelp:for:
category of:
#hideIfPointerLeft:
#initiateHelpFor:at:now:
--- a/FlyByHelp.st Fri Jun 08 10:32:31 2018 +0200
+++ b/FlyByHelp.st Fri Jun 08 10:33:04 2018 +0200
@@ -16,10 +16,10 @@
"{ NameSpace: Smalltalk }"
ActiveHelp subclass:#FlyByHelp
- instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess'
- classVariableNames:'MaxNumberOfLines MaxNumberOfColumns'
- poolDictionaries:''
- category:'Interface-Help'
+ instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess'
+ classVariableNames:'MaxNumberOfLines MaxNumberOfColumns'
+ poolDictionaries:''
+ category:'Interface-Help'
!
!FlyByHelp class methodsFor:'documentation'!
@@ -259,24 +259,84 @@
"Modified (format): / 07-06-2018 / 09:51:41 / sr"
! !
-!FlyByHelp methodsFor:'private'!
+!FlyByHelp methodsFor:'queries'!
+
+currentlyShownView
+ ^ currentHelpView
+!
+
+toolTipFollowsMouse
+ "if true, the tooltip-window moves with the pointer
+ so that it stays away from (does not cover) the mouse pointer"
+
+ ^ false
+
+ "Modified: / 06-06-2018 / 17:37:19 / Claus Gittinger"
+! !
+
+!FlyByHelp methodsFor:'show & hide help'!
+
+activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice
+ applicationOrNil notNil ifTrue:[
+ ^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice
+ ].
+ ^ ActiveHelpView for:helpText onDevice:aDevice.
+
+ "
+ (ActiveHelpView for:'Hello' onDevice:Display) open
+ "
+!
+
+hideHelp
+ "hide the help text"
+
+ |p|
+
+ "/ lastHelpText := nil.
+ self stopHelpDisplayProcess.
+ lastHelpText := nil.
+
+ currentHelpView notNil ifTrue:[
+ [
+ currentHelpView notNil ifTrue:[
+ currentHelpView destroy.
+ currentHelpView := nil.
+ currentView := nil.
+ ]
+ ] valueUninterruptably
+ ].
+ currentFrame := nil.
+ (p := closeProcess) notNil ifTrue:[
+ closeProcess := nil.
+ p terminate.
+ ]
+
+ "Modified: / 28-06-1997 / 14:03:50 / cg"
+ "Modified: / 16-04-2018 / 16:51:01 / stefan"
+!
hideIfPointerLeft:aView
"hide help, if the pointer is not in aView"
- |whereOnScreen|
+ |helpFrame whereOnScreen|
- currentFrame notNil ifTrue:[
+ (helpFrame := currentFrame) notNil ifTrue:[
whereOnScreen := aView graphicsDevice pointerPosition.
- (currentFrame notNil
- and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[
+ ((helpFrame insetBy:1@1) containsPoint:whereOnScreen) ifFalse:[
self hideHelp.
- ].
+ ] ifTrue:[
+ pointerPositionAtShowTime notNil ifTrue:[
+ (whereOnScreen dist:pointerPositionAtShowTime) > 10 ifTrue:[
+ self hideHelp.
+ ].
+ ].
+ ].
].
"Modified: / 28-05-1996 / 20:18:28 / cg"
"Modified: / 16-04-2018 / 16:59:48 / stefan"
+ "Modified: / 08-06-2018 / 10:30:04 / Claus Gittinger"
!
initiateHelpFor:aView at:aPointOrNil now:showItNow
@@ -351,62 +411,6 @@
"Modified: / 22-03-2011 / 19:10:28 / cg"
"Modified: / 16-04-2018 / 12:20:33 / stefan"
"Modified: / 06-06-2018 / 17:19:26 / Claus Gittinger"
-! !
-
-!FlyByHelp methodsFor:'queries'!
-
-currentlyShownView
- ^ currentHelpView
-!
-
-toolTipFollowsMouse
- "if true, the tooltip-window moves with the pointer
- so that it stays away from (does not cover) the mouse pointer"
-
- ^ false
-
- "Modified: / 06-06-2018 / 17:37:19 / Claus Gittinger"
-! !
-
-!FlyByHelp methodsFor:'show & hide help'!
-
-activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice
- applicationOrNil notNil ifTrue:[
- ^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice
- ].
- ^ ActiveHelpView for:helpText onDevice:aDevice.
-
- "
- (ActiveHelpView for:'Hello' onDevice:Display) open
- "
-!
-
-hideHelp
- "hide the help text"
-
- |p|
-
- "/ lastHelpText := nil.
- self stopHelpDisplayProcess.
- lastHelpText := nil.
-
- currentHelpView notNil ifTrue:[
- [
- currentHelpView notNil ifTrue:[
- currentHelpView destroy.
- currentHelpView := nil.
- currentView := nil.
- ]
- ] valueUninterruptably
- ].
- currentFrame := nil.
- (p := closeProcess) notNil ifTrue:[
- closeProcess := nil.
- p terminate.
- ]
-
- "Modified: / 28-06-1997 / 14:03:50 / cg"
- "Modified: / 16-04-2018 / 16:51:01 / stefan"
!
showHelp:aHelpText for:view
@@ -414,7 +418,7 @@
|wg applicationOrNil org p v device helpTextShown textLines
helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight
- showTime cursorView pos|
+ showTime cursorView pos pointerPosition|
"/ thisContext fullPrintAllOn:Transcript.
(wg := view windowGroup) notNil ifTrue:[
@@ -426,9 +430,10 @@
].
device := view graphicsDevice.
-
+ pointerPosition := device pointerPosition.
+
"/ mouse still over that view?
- cursorView := device viewFromPoint:(device pointerPosition).
+ cursorView := device viewFromPoint:pointerPosition.
cursorView ~~ view ifTrue:[
Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ].
^ self
@@ -437,6 +442,8 @@
(view == currentView and:[lastHelpText = aHelpText]) ifTrue:[
^ self
].
+
+ pointerPositionAtShowTime := pointerPosition.
lastHelpWidget := view.
lastHelpText := aHelpText.
helpTextShown := aHelpText.
@@ -531,7 +538,7 @@
"Modified: / 31-08-1995 / 19:20:45 / claus"
"Modified: / 06-06-2017 / 15:06:41 / cg"
"Modified (format): / 16-04-2018 / 17:29:10 / stefan"
- "Modified (comment): / 07-06-2018 / 10:34:02 / Claus Gittinger"
+ "Modified: / 08-06-2018 / 10:28:32 / Claus Gittinger"
!
stopHelpDisplayProcess