CharacterSetView.st
changeset 5985 93b6ba79239b
parent 5984 ba363b1766e4
child 6108 218347e50097
--- a/CharacterSetView.st	Tue Jan 08 18:09:16 2019 +0100
+++ b/CharacterSetView.st	Tue Jan 08 18:26:49 2019 +0100
@@ -17,7 +17,7 @@
 
 View subclass:#CharacterSetView
 	instanceVariableNames:'codePageHolder selectedCodePointHolder masterViewOrNil
-		encoderOrNil consumingView'
+		encoderOrNil'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Special'
@@ -152,15 +152,17 @@
             [:char | 
                 |pastedString|
 
-                pastedString := (CharacterEncoder encode:char from:aConsumingView characterEncoding into:#unicode) asCharacter asString.
-                htmlHolder value ifTrue:[
-                    "/ insert html
-                    pastedString := HTMLUtilities escapeCharacterEntities:pastedString.
-                ].
-                pastedString do:[:eachChar |
-                    aConsumingView dispatchEvent:(WindowEvent keyPress:eachChar x:0 y:0 view:v).
-                    aConsumingView dispatchEvent:(WindowEvent keyRelease:eachChar x:0 y:0 view:v).
-                ].
+                (v consumingView notNil and:[v consumingView shown]) ifTrue:[
+                    pastedString := (CharacterEncoder encode:char from:v consumingView characterEncoding into:#unicode) asCharacter asString.
+                    htmlHolder value ifTrue:[
+                        "/ insert html
+                        pastedString := HTMLUtilities escapeCharacterEntities:pastedString.
+                    ].
+                    pastedString do:[:eachChar |
+                        v consumingView dispatchEvent:(WindowEvent keyPress:eachChar x:0 y:0 view:v).
+                        v consumingView dispatchEvent:(WindowEvent keyRelease:eachChar x:0 y:0 view:v).
+                    ].
+               ].
            ].
     ].
 
@@ -204,7 +206,7 @@
             ].
             codePointLabel repairDamage.
 
-            aConsumingView notNil ifTrue:[
+            v consumingView notNil ifTrue:[
                 selectedCodePoint notNil ifTrue:[
                     insertCharacter value:(Character value:selectedCodePoint).
                     v selectedCodePointHolder setValue:nil.
@@ -358,7 +360,7 @@
 
     "Modified: / 11-10-2006 / 22:30:32 / cg"
     "Modified: / 19-01-2018 / 12:16:03 / stefan"
-    "Modified: / 08-01-2019 / 14:13:15 / Claus Gittinger"
+    "Modified: / 08-01-2019 / 18:27:12 / Claus Gittinger"
 !
 
 openOn:aFont label:viewLabel clickLabel:clickLabel
@@ -370,7 +372,7 @@
 !
 
 openOn:aFont label:viewLabel clickLabel:clickLabel asInputFor:aView
-    self
+    ^ self
         openOn:aFont 
         label:viewLabel 
         clickLabel:clickLabel 
@@ -381,6 +383,8 @@
      self openOn:(View defaultFont).
      self openOn:(Font family:'courier' face:'medium' style:'roman' size:12 encoding:'iso10646-1').
     "
+
+    "Modified: / 08-01-2019 / 18:17:33 / Claus Gittinger"
 !
 
 openOn:aFont label:viewLabel clickLabel:clickLabel asInputFor:aConsumingView encoder:aCharacterEncoderOrNil
@@ -445,6 +449,12 @@
     ^ codePageHolder
 !
 
+consumingView
+    ^ masterViewOrNil
+
+    "Created: / 08-01-2019 / 18:16:44 / Claus Gittinger"
+!
+
 encoder:aCharacterEncoder
     encoderOrNil := aCharacterEncoder
 !
@@ -612,9 +622,9 @@
     ].
 
     key == #Escape ifTrue:[
-        consumingView notNil ifTrue:[
+        masterViewOrNil notNil ifTrue:[
             self topView closeRequest.
-            consumingView requestFocus.
+            masterViewOrNil requestFocus.
         ].
         ^ self.
     ].
@@ -623,9 +633,9 @@
         "/ others are forwarded to the controlled view
         selectedCodePointHolder value:key codePoint.
     ] ifFalse:[
-        consumingView notNil ifTrue:[
-            consumingView keyPress:key x:0 y:0.
-            consumingView keyRelease:key x:0 y:0.
+        (masterViewOrNil notNil and:[masterViewOrNil shown]) ifTrue:[
+            masterViewOrNil keyPress:key x:0 y:0.
+            masterViewOrNil keyRelease:key x:0 y:0.
             ^ self.
         ] ifFalse:[
             cp := selectedCodePointHolder value ? 0. 
@@ -654,7 +664,7 @@
     super keyPress:key x:x y:y
 
     "Modified: / 12-07-2012 / 12:25:50 / cg"
-    "Modified: / 08-01-2019 / 15:50:02 / Claus Gittinger"
+    "Modified: / 08-01-2019 / 18:26:17 / Claus Gittinger"
 !
 
 selectedCodePointChanged
@@ -667,9 +677,10 @@
 !CharacterSetView methodsFor:'initialization & release'!
 
 consumingView:aView
-    consumingView := aView.
+    masterViewOrNil := aView.
 
     "Created: / 08-01-2019 / 11:23:30 / Claus Gittinger"
+    "Modified: / 08-01-2019 / 18:20:33 / Claus Gittinger"
 !
 
 destroy