[Pkg] The Trunk: Morphic-mt.902.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Apr 19 10:32:49 UTC 2015


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.902.mcz

==================== Summary ====================

Name: Morphic-mt.902
Author: mt
Time: 19 April 2015, 12:32:11.486 pm
UUID: 2c3dcf2c-eef7-b049-b897-6f96d56df176
Ancestors: Morphic-mt.901

Fixed and extended the default morphic event handler to support #keyUp, #keyDown, and #keyboardFocusChange.

=============== Diff against Morphic-mt.901 ===============

Item was changed:
  Object subclass: #EventHandler
+ 	instanceVariableNames: 'mouseDownRecipient mouseDownSelector mouseMoveRecipient mouseMoveSelector mouseStillDownRecipient mouseStillDownSelector mouseUpRecipient mouseUpSelector mouseEnterRecipient mouseEnterSelector mouseLeaveRecipient mouseLeaveSelector mouseEnterDraggingRecipient mouseEnterDraggingSelector mouseLeaveDraggingRecipient mouseLeaveDraggingSelector keyStrokeRecipient keyStrokeSelector keyUpRecipient keyUpSelector keyDownRecipient keyDownSelector valueParameter startDragRecipient startDragSelector doubleClickSelector doubleClickRecipient doubleClickTimeoutSelector doubleClickTimeoutRecipient clickSelector clickRecipient keyboardFocusChangeRecipient keyboardFocusChangeSelector'
- 	instanceVariableNames: 'mouseDownRecipient mouseDownSelector mouseMoveRecipient mouseMoveSelector mouseStillDownRecipient mouseStillDownSelector mouseUpRecipient mouseUpSelector mouseEnterRecipient mouseEnterSelector mouseLeaveRecipient mouseLeaveSelector mouseEnterDraggingRecipient mouseEnterDraggingSelector mouseLeaveDraggingRecipient mouseLeaveDraggingSelector keyStrokeRecipient keyStrokeSelector valueParameter startDragRecipient startDragSelector doubleClickSelector doubleClickRecipient doubleClickTimeoutSelector doubleClickTimeoutRecipient clickSelector clickRecipient'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Morphic-Events'!
  
  !EventHandler commentStamp: '<historical>' prior: 0!
  Events in Morphic originate in a Hand, pass to a target morph, and are then dispatched by an EventHandler.  EventHandlers support redirection of mouse and keyboard activity by specifying and independent recipient object and message selector for each of the possible events.  In addition each eventHandler can supply an optional value parameter for distinguishing between, eg, events from a number of otherwise identical source morphs.
  
  The basic protocol of an event handler is to receive a message of the form
  	mouseDown: event in: targetMorph
  and redirect this as one of
  	mouseDownRecipient perform: mouseDownSelector0
  	mouseDownRecipient perform: mouseDownSelector1 with: event
  	mouseDownRecipient perform: mouseDownSelector2 with: event with: targetMorph
  	mouseDownRecipient perform: mouseDownSelector3 with: event with: targetMorph with: valueParameter
  depending on the arity of the mouseDownSelector.
  !

Item was added:
+ ----- Method: EventHandler>>keyDown:fromMorph: (in category 'events') -----
+ keyDown: event fromMorph: sourceMorph
+ 	^ self send: keyDownSelector to: keyDownRecipient withEvent: event fromMorph: sourceMorph!

Item was added:
+ ----- Method: EventHandler>>keyUp:fromMorph: (in category 'events') -----
+ keyUp: event fromMorph: sourceMorph
+ 	^ self send: keyUpSelector to: keyUpRecipient withEvent: event fromMorph: sourceMorph!

Item was added:
+ ----- Method: EventHandler>>keyboardFocusChange:fromMorph: (in category 'events') -----
+ keyboardFocusChange: aBoolean fromMorph: sourceMorph
+ 
+ 	^ self
+ 		send: keyboardFocusChangeSelector
+ 		to: keyboardFocusChangeRecipient
+ 		withEvent: aBoolean
+ 		fromMorph: sourceMorph!

Item was changed:
  ----- Method: EventHandler>>on:send:to: (in category 'initialization') -----
  on: eventName send: selector to: recipient
  	eventName == #mouseDown ifTrue:
  		[mouseDownRecipient := recipient.  mouseDownSelector := selector. ^ self].
  	eventName == #mouseMove ifTrue:
  		[mouseMoveRecipient := recipient.  mouseMoveSelector := selector. ^ self].
  	eventName == #mouseStillDown ifTrue:
  		[mouseStillDownRecipient := recipient.  mouseStillDownSelector := selector. ^ self].
  	eventName == #mouseUp ifTrue:
  		[mouseUpRecipient := recipient.  mouseUpSelector := selector. ^ self].
  	eventName == #mouseEnter ifTrue:
  		[mouseEnterRecipient := recipient.  mouseEnterSelector := selector. ^ self].
  	eventName == #mouseLeave ifTrue:
  		[mouseLeaveRecipient := recipient.  mouseLeaveSelector := selector. ^ self].
  	eventName == #mouseEnterDragging ifTrue:
  		[mouseEnterDraggingRecipient := recipient.  mouseEnterDraggingSelector := selector. ^ self].
  	eventName == #mouseLeaveDragging ifTrue:
  		[mouseLeaveDraggingRecipient := recipient.  mouseLeaveDraggingSelector := selector. ^ self].
  	eventName == #click ifTrue:
  		[clickRecipient := recipient. clickSelector := selector. ^ self].
  	eventName == #doubleClick ifTrue:
  		[doubleClickRecipient := recipient. doubleClickSelector := selector. ^ self].
  	eventName == #doubleClickTimeout ifTrue:
  		[doubleClickTimeoutRecipient := recipient. doubleClickTimeoutSelector := selector. ^ self].
  	eventName == #startDrag ifTrue:
  		[startDragRecipient := recipient. startDragSelector := selector. ^ self].
  	eventName == #keyStroke ifTrue:
  		[keyStrokeRecipient := recipient.  keyStrokeSelector := selector. ^ self].
+ 	eventName == #keyUp ifTrue:
+ 		[keyUpRecipient := recipient.  keyUpSelector := selector. ^ self].
+ 	eventName == #keyDown ifTrue:
+ 		[keyDownRecipient := recipient.  keyDownSelector := selector. ^ self].
+ 	eventName == #keyboardFocusChange ifTrue:
+ 		[keyboardFocusChangeRecipient := recipient. keyboardFocusChangeSelector := selector. ^ self].
  	eventName == #gesture ifTrue:
  		[ ^self onGestureSend: selector to: recipient ].
  	self error: 'Event name, ' , eventName , ' is not recognizable.'
  !

Item was changed:
  ----- Method: Morph>>keyDown: (in category 'event handling') -----
  keyDown: anEvent
+ 	"Handle a key down event. The default response is to let my eventHandler, if any, handle it."
+ 
+ 	self eventHandler ifNotNil:
+ 		[self eventHandler keyDown: anEvent fromMorph: self].
+ !
- 	"Handle a key down event. The default response is to do nothing."!

Item was changed:
  ----- Method: Morph>>keyUp: (in category 'event handling') -----
  keyUp: anEvent
+ 	"Handle a key up event. The default response is to let my eventHandler, if any, handle it."
+ 
+ 	self eventHandler ifNotNil:
+ 		[self eventHandler keyUp: anEvent fromMorph: self].
+ !
- 	"Handle a key up event. The default response is to do nothing."!

Item was changed:
  ----- Method: Morph>>keyboardFocusChange: (in category 'event handling') -----
  keyboardFocusChange: aBoolean
+ 	"The message is sent to a morph when its keyboard focus change. The given argument indicates that the receiver is gaining keyboard focus (versus losing) the keyboard focus. Morphs that accept keystrokes should change their appearance in some way when they are the current keyboard focus."
- 	"The message is sent to a morph when its keyboard focus change. The given argument indicates that the receiver is gaining keyboard focus (versus losing) the keyboard focus. Morphs that accept keystrokes should change their appearance in some way when they are the current keyboard focus. This default implementation does nothing."
  
+ 	self eventHandler
+ 		ifNotNil: [:h | h keyboardFocusChange: aBoolean fromMorph: self].
+ 
+ 	self indicateKeyboardFocus
+ 		ifTrue: [self changed].!
- 	self indicateKeyboardFocus ifTrue: [self changed].!



More information about the Packages mailing list