CS 683 Emerging Technologies: Embracing Change Spring Semester, 2001 Morphic Intro |
||
---|---|---|
© 2001, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 12-Apr-01 |
Morphic
New interface experiment from Self
Goals were:
Morphs
Live an a world
Can interact with
Basic Interaction
Simple Events
Keyboard
Mouse
Drag & Drop
Keyboard Events
Three types in order sent
isKeyDown |
anyModifierKeyPressed
|
isKeyUp
|
commandKeyPressed
|
isKeyboard
|
controlKeyPressed
|
isKeystroke |
macOptionKeyPressed
|
keyCharacter
|
shiftPressed |
keyValue |
|
To Actually handle Keyboard Events
Morph subclass must implement
keyDown: anEvent
keyStroke: anEvent
keyUp: anEvent
Handling Mouse Events
A Morph subclass must override one or more of the following methods to be notified of the event
Return true to handle the event
handlesKeyboard: aMouseButtonEvent handlesMouseDown: aMouseButtonEvent handlesMouseOver: aMouseButtonEvent handlesMouseOverDragging: aMouseButtonEvent handlesMouseStillDown: aMouseButtonEvent
To handle the event implement one of:
mouseDown: aMouseButtonEvent mouseEnter: aMouseButtonEvent mouseEnterDragging: aMouseButtonEvent mouseLeave: aMouseButtonEvent mouseLeaveDragging: aMouseButtonEvent mouseMove: aMouseButtonEvent mouseStillDown: aMouseButtonEvent mouseStillDownThreshold aMouseButtonEvent mouseUp: aMouseButtonEvent
Important MouseButtonEvent Methods
isDraggingEvent
|
anyButtonPressed
|
isMouse
|
blueButtonPressed
|
isMouseDown
|
cursorPoint
|
isMouseEnter
|
redButtonPressed
|
isMouseLeave
|
targetPoint
|
isMouseMove
|
yellowButtonPressed |
isMouseUp
|
|
isMove |
|
Drawing
To change the image of the Morph subClass
Override the method
drawOn: aCanvas
Stepping
Morphs are active
Periodically they are sent the message step
This method can perform animation etc.
The time between sending step is determined by the method
Example
Morph subclass: #TestMorphic instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Whitney-Morphic'! step self world bounds bottom > self bottom ifTrue:[self bottom: (self bottom + 3) stepTime ^500 handlesKeyboard: aKeyBoardEvent ^aKeyBoardEvent isKeystroke keyStroke: anEvent Transcript show: 'You pressed key '; show: anEvent keyCharacter; cr. drawOn: aCanvas aCanvas fillOval: self bounds color: Color red
Copyright ©, All rights reserved.
2001 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.
Previous    visitors since 12-Apr-01    Next