From VisualWorks®, Pre-Release 7.1 - mar03.1 of March 3, 2003 on March 19, 2003 at 8:08:38 am (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <name>DocumentName</name> <environment>OS.MacOSXSystemSupport</environment> <private>false</private> <constant>false</constant> <category>document support</category> <initializer>nil</initializer> <attributes> <package>MacOSXExtra</package> </attributes> <name>NewDocumentSemaphore</name> <environment>OS.MacOSXSystemSupport</environment> <private>false</private> <constant>false</constant> <category>document support</category> <initializer>Semaphore new</initializer> <attributes> <package>MacOSXExtra</package> </attributes> <name>MacOSXMenuDispatch</name> <environment>UI.InputState</environment> <private>false</private> <constant>false</constant> <category>dispatch table</category> <initializer>nil</initializer> <attributes> <package>MacOSXExtra</package> </attributes> <methods> OS.MacOSXSystemSupport class <category>change update</category>
update: anAspect with: aParam from: anObject "On returnFromSnapshot, look for a document dropped on to the application, and signal the semaphore, if any." "ObjectMemory removeDependent: self. ObjectMemory addDependent: self" super update: anAspect with: aParam from: anObject. anAspect == #returnFromSnapshot ifTrue: [self enableMenuBarItems. self getInitialDocument]
</methods> <methods> OS.MacOSXSystemSupport class <category>primitives</category>
primGetDocumentName "Get and clear one document name from the VM. If there is none, return nil." <primitive: 761>
</methods> <methods> UI.InputState <category>private macosx dispatching</category>
visualWorksSettings: window eventMenu: event "Open the VisualWorks SettingsTool." [Tools.VisualWorksSettings openManager] forkAt: 50
quitVisualWorks: window eventMenu: event "Quit VisualWorks using the standard 'Quit' dialog." [ObjectMemory quitDialog] forkAt: 50
</methods> <methods> OS.MacOSXSystemSupport class <category>class initialization</category>
initialize super initialize. Screen default platformName = 'MacOSX' ifFalse: [^self]. InputState setMenuDispatchTable.
</methods> <methods> OS.MacOSXSystemSupport class <category>class accessing</category>
getDocumentNames "Get all document names from the VM that were dropped on the executable. This clears the names from the VM storage for such names." | names temp | names := OrderedCollection new. DocumentName notNil ifTrue: [names add: DocumentName. DocumentName := nil]. [(temp := self primGetDocumentName) notNil] whileTrue: [names add: temp asString]. ^names
</methods> <methods> OS.MacOSXSystemSupport class <category>change update</category>
getInitialDocument "This is a demo of how to get document names dropped onto the VM on startup." Screen default platformName = 'MacOSX' ifFalse: [^self]. Transcript show: 'Docname fetch ..'; cr. DocumentName := self primGetDocumentName. DocumentName notNil ifTrue: [DocumentName := DocumentName asString. self newDocumentSemaphore signal]
</methods> <methods> UI.InputState <category>private macosx dispatching</category>
helpTopics: window eventMenu: event "Open the VisualWorks 'Topics' help window as done by the VisualLaunchers Help->Topics menu." [#{VWHelp.HelpBrowser} ifDefinedDo: [:v | ] elseDo: [Parcel ensureLoadedParcel: 'VWHelp' withVersion: '']. #{VWHelp.HelpBrowser} ifDefinedDo: [:v | v open]] forkAt: 50
aboutVisualWorks: window eventMenu: event "Open the VisualWorks 'About' window as done by the VisualLauncher." [AboutVisualWorksDialog open] forkAt: 50
selectAll: window eventMenu: event self send: window eventKeyPress: event
</methods> <methods> UI.InputState class <category>class initialization</category>
setDispatchTableForPlatform "Some old platforms have poor event or window behaviour. Add the check here at start-up rather than on every event because the dispatch table provides a convenient mechanism." | platformName | EventDispatchTable at: 6 put: #send:eventMouseMoved:. platformName := Screen default platformName. platformName = 'Mac' ifTrue: [EventDispatchTable at: 6 put: #send:eventMouseMovedMaybeWrongButtons:]. platformName = 'MacOSX' ifTrue: [self setMenuDispatchTable]. [ObjectMemory registerObject: true withEngineFor: 'acceptQuitEvents'] on: Error do: [:ex | ex return]
</methods> <methods> UI.InputState class <category>accessing</category>
macOSXMenuDispatch "Lazy initialize the MacOSXMenuDispatch variable." MacOSXMenuDispatch isNil ifTrue: [self setMenuDispatchTable]. ^MacOSXMenuDispatch
</methods> <methods> OS.MacOSXSystemSupport class <category>change update</category>
enableMenuBarItems "On #returnFromSnapshot setup the MacOS X menu bar items." Screen default platformName = 'MacOSX' ifFalse: [^self]. self primActivateMenuItem: 1 state: true. "VisualWorks->About VisualWorks..." self primActivateMenuItem: 2 state: true. "VisualWorks->Preferences" self primActivateMenuItem: 3 state: true. "VisualWorks->Quit" " self primActivateMenuItem: 11 state: true." "Edit->Undo" " self primActivateMenuItem: 12 state: true." "Edit->Again" " self primActivateMenuItem: 16 state: true." "Edit->Clear" self primActivateMenuItem: 17 state: true. "Edit->Select All" self primActivateMenuItem: 32 state: true. "Help->Topics"
</methods> <methods> OS.MacOSXSystemSupport class <category>examples</category>
simpleDocumentHandling "To catch open document events in VisualWorks, MacOSXSystemSupport provides some class side facilities: getDocumentNames - retrieves names of files of open document events, after fetching them, they have to be processed by the caller, because the fetch clears the storage for names in the VM, newDocumentSemaphore - this semaphore is signaled as soon as an open document event arrives, To be able to receive these events on start up of the image, class MacOSXSystemSupport has to be registered as a dependent of ObjectMemory. The code of this method serves as an example of a process waiting for open document events. Each time the newDocumentSemaphore is signaled, it will fetch all document names and open a FileBrowser on each. This example only works, if Textfiles are accepted by the VM. A standard VM does not accept txt-files, so you have to edit the file visual.app/Contents/Info.plist and add another entry into CFBundleDocumentTypes. Look at the Info.plist file of application TextEdit for examples. Executing the following code will start the example process: MacOSXSystemSupport simpleDocumentHandling" [[MacOSXSystemSupport newDocumentSemaphore wait. MacOSXSystemSupport getDocumentNames do: [ :each | Tools.FileBrowser openOnFileNamed: each]] repeat] fork
</methods> <methods> UI.InputState class <category>class initialization</category>
setMenuDispatchTable "Set up the global EventDispatchTable to process host menubar events, then initialize the MacOSX specific dispatch table for events originated from menu bar picks. As a default, only special items of the default menu bar, as shipped by Cincom, are registered and enabled." EventDispatchTable at: 16 put: #send:eventMenu:. MacOSXMenuDispatch := Dictionary new. MacOSXMenuDispatch at: 1 put: #aboutVisualWorks:eventMenu:. MacOSXMenuDispatch at: 2 put: #visualWorksSettings:eventMenu:. MacOSXMenuDispatch at: 3 put: #quitVisualWorks:eventMenu:. MacOSXMenuDispatch at: 11 put: #undo:eventMenu:. MacOSXMenuDispatch at: 12 put: #redo:eventMenu:. MacOSXMenuDispatch at: 16 put: #clear:eventMenu:. MacOSXMenuDispatch at: 17 put: #selectAll:eventMenu:. MacOSXMenuDispatch at: 32 put: #helpTopics:eventMenu:.
</methods> <methods> OS.MacOSXSystemSupport class <category>class accessing</category>
newDocumentSemaphore "This semaphore is signalled each time a document event is received on MacOS X." NewDocumentSemaphore isNil ifTrue: [NewDocumentSemaphore := Semaphore new]. ^NewDocumentSemaphore
</methods> <methods> UI.InputState <category>private</category>
processUnboundEvent: event "There is no window corresponding to this event. This may mean that the event is not bound to any window, or that the window is not owned by Smalltalk, or that the window was owned by Smalltalk, but Smalltalk has already destroyed this window." "If running on MacOS X, signal the NewDocumentSemaphore, because this type of event is send in case an open document event has arrived." Screen default platformName = 'MacOSX' ifTrue: [MacOSXSystemSupport newDocumentSemaphore signal]. eventDispatcher == nil ifFalse: [eventDispatcher dispatchEvent: event]
</methods> <methods> OS.MacOSXSystemSupport class <category>primitives</category>
primActivateMenuItem: tagNumber state: aBooleanOrNil "MacOS X only primitve! Set the state of the menubar item with tagNumber to aBooleanOrNil, that is on, off, or default. As soon as the menu item is enabled, menu events are generated by this item. Setting the menu item state to nil will restore the original state of the menu. Returns a boolean, telling you its activation state before the call." <primitive: 778> ^self primitiveFailed
</methods> <methods> UI.InputState <category>private dispatching</category>
send: window eventMenu: event "This is the hook for host menubar events on MacOS X." | focusWindow menuItemSelector | focusWindow := self focusWindowOr: window. focusWindow ifNil: [^self]. event at: 2 put: focusWindow key. menuItemSelector := self class macOSXMenuDispatch at: (event at: 8) ifAbsent: [nil]. menuItemSelector isNil ifTrue: [" focusWindow sensor eventMenu: event "] ifFalse: [ self perform: menuItemSelector with: focusWindow with: event ].
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>InputState</name> <environment>UI</environment> <super>Core.Object</super> <private>false</private> none x y bitState shiftState ctrlState lockState metaState metaKeyState otherMetaKey1State activitySemaphore lastEventTime lastClick eventDispatcher lastDownPoint lastUpPoint lastUpButton lastWindow <imports></imports> <category>OS-Window System</category> <attributes> <package>OS-Window System</package> </attributes> </class>