SDSU CS 683 Emerging Technologies: Embracing Change
Spring Semester, 2001
Morphic Intro
Previous    Lecture Notes Index    Next    
© 2001, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 12-Apr-01

Contents of Doc 20, Morphic Intro


Reference

Squeak: Object-Oriented Design with Multimedia Applications, Guzdial, Chapter 5


Doc 20, Morphic Intro Slide # 2

Morphic


New interface experiment from Self

Goals were:

Language supports
Direct, copy & modify style of programming
Interface supports
Immediate & direct access to all parts of application even when running
Language
Merges state and behavior
Uses objects & messages for everything
Interface
Uses graphical objects down to the lowest level
Removes the distinction between run and edit


Doc 20, Morphic Intro Slide # 3

Morphs


Live an a world

Can interact with

Can be programmed with:


Doc 20, Morphic Intro Slide # 4
Basic Interaction

Simple Events

Keyboard
Mouse
Drag & Drop


Doc 20, Morphic Intro Slide # 5

Keyboard Events


Three types in order sent

Contains key pressed

To handle keyboard events Morph subclass must implement:

handlesKeyboard: anKeyboardEvent

The method must return true for the types of events of interest


Important KeyboardEvent Methods

isKeyDown
anyModifierKeyPressed
isKeyUp
commandKeyPressed
isKeyboard
controlKeyPressed
isKeystroke
macOptionKeyPressed
keyCharacter
shiftPressed
keyValue



Doc 20, Morphic Intro Slide # 6
To Actually handle Keyboard Events

Morph subclass must implement

keyDown: anEvent
keyStroke: anEvent
keyUp: anEvent



Doc 20, Morphic Intro Slide # 7

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


Doc 20, Morphic Intro Slide # 8
Important MouseButtonEvent Methods

isDraggingEvent
anyButtonPressed
isMouse
blueButtonPressed
isMouseDown
cursorPoint
isMouseEnter
redButtonPressed
isMouseLeave
targetPoint
isMouseMove
yellowButtonPressed
isMouseUp

isMove



Doc 20, Morphic Intro Slide # 9

Drawing


To change the image of the Morph subClass

Override the method

drawOn: aCanvas


Doc 20, Morphic Intro Slide # 10

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

stepTime
This method returns time in milliseconds

To start stepping send:

startStepping
To send stepping send:

endStepping


Doc 20, Morphic Intro Slide # 11
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