MenuEditor.st
changeset 356 269c117830ba
parent 340 1de048872d5e
child 359 6193ef5b6e74
--- a/MenuEditor.st	Tue Oct 28 21:26:55 1997 +0100
+++ b/MenuEditor.st	Wed Oct 29 08:33:56 1997 +0100
@@ -13,8 +13,8 @@
 
 
 ApplicationModel subclass:#MenuEditor
-	instanceVariableNames:'specClass specCanvas helpCanvas tabSelection aspects slices
-		didInstall'
+	instanceVariableNames:'isModified specClass specCanvas helpCanvas tabSelection aspects
+		slices didInstall'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -466,16 +466,19 @@
                 #'label:' 'copy'
                 #'value:' #doCopy
                 #'enabled:' #hasValidSelection
+                #'shortcutKeyCharacter:' #Copy
             )
              #(#MenuItem
                 #'label:' 'cut'
                 #'value:' #doCut
                 #'enabled:' #hasValidSelection
+                #'shortcutKeyCharacter:' #Cut
             )
              #(#MenuItem
                 #'label:' 'paste'
                 #'value:' #doPaste
                 #'enabled:' #hasAnySingleSelection
+                #'shortcutKeyCharacter:' #Paste
             )
              #(#MenuItem
                 #'label:' '-'
@@ -1380,7 +1383,7 @@
         ]
     ].
     self modifiedChannel value:false.
-    didInstall := true
+    isModified := true.
 !
 
 cancel
@@ -1502,7 +1505,7 @@
 update:something with:aParameter from:changedObject
     "one of my models changed its value
     "
-    self modifiedChannel value:true
+    self modifiedChannel value:true.
 !
 
 updateEnabledChannels
@@ -1576,9 +1579,7 @@
     "returns true if the menu was installed
     "
 
-    ^ didInstall ? false
-
-    "Created: 31.7.1997 / 14:24:24 / cg"
+    ^ didInstall
 !
 
 isHelpToolSelected
@@ -1695,6 +1696,22 @@
     self painter buildFrom:newClass andSelector:aSelector.
 !
 
+closeRequest
+    "close request
+    "
+    isModified ifTrue:[
+        (self confirm:'quit without without saving your modifications ?') ifFalse:[
+            ^ self
+        ]
+    ].
+    super closeRequest.
+
+
+
+
+
+!
+
 initialize
     "initialize channels
     "
@@ -1746,6 +1763,9 @@
 postBuildWith:builder
     |cls sel|
 
+    didInstall := false.
+    isModified := false.
+
     specClass isAssociation ifTrue:[
         cls := specClass key.
         sel := specClass value.
@@ -1763,20 +1783,6 @@
 
 !MenuEditor methodsFor:'user interactions'!
 
-closeRequest
-    "close the window - confirm if changed without saving
-    "
-    self modifiedChannel value ifTrue:[
-        (self confirm:'quit without without saving your modifications ?') ifFalse:[
-            ^ self
-        ]
-    ].
-
-    super closeRequest.
-
-    "Modified: 31.7.1997 / 14:29:10 / cg"
-!
-
 doBrowseAppClass
     "open a browser on the class"
 
@@ -1879,7 +1885,8 @@
         code := code withCRs.
         (ReadStream on:code) fileIn.
     ].
-
+    didInstall := true.
+    isModified := false.
 
 !
 
@@ -2406,6 +2413,24 @@
     ^ images at:#menuOpen
 ! !
 
+!MenuEditor::Painter methodsFor:'event handling'!
+
+keyPress:key x:x y:y
+    "any key pressed
+    "
+    <resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste ) >
+
+    (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
+        ^ self doCut
+    ].
+
+    key == #Copy  ifTrue:[ ^ self doCopy].
+    key == #Paste ifTrue:[ ^ self doPaste].
+
+    super keyPress:key x:x y:y.
+
+! !
+
 !MenuEditor::Painter methodsFor:'initialization'!
 
 fetchImageResources