[squeak-dev] Getting morph events when there is no keyboard focus

Bob Arning arning315 at comcast.net
Tue Jul 23 23:19:06 UTC 2013


'From Squeak4.4 of 1 March 2013 [latest update: #12489] on 23 July 2013 
at 7:17:36 pm'!
Morph subclass: #TimsAppMorph
     instanceVariableNames: ''
     classVariableNames: ''
     poolDictionaries: ''
     category: 'Morphic-Kernel'!
!TimsAppMorph commentStamp: 'raa 7/23/2013 19:08' prior: 0!
TimsAppMorph new openInWorld!


!TimsAppMorph methodsFor: 'as yet unclassified' stamp: 'raa 7/23/2013 
19:16'!
handleListenEvent: anEvent

     anEvent hand keyboardFocus ifNotNil: [^self].
     anEvent isKeyboard ifFalse: [^self].

     "insert your code here to handle key up/down/stroke as you wish"

     Transcript show: 'I could handle: ', anEvent  asString; cr
     ! !

!TimsAppMorph methodsFor: 'as yet unclassified' stamp: 'raa 7/23/2013 
19:08'!
initialize

     super initialize.
     self extent: 60 at 60.
     self color: Color paleBlue.
     ActiveHand addKeyboardListener: self.! !


On 7/23/13 6:41 PM, tim Rowledge wrote:
> I'm trying to get an idea of how to handle keyboard events when there is no keyboard focus; this is for dealing with  general application commands like 'start', 'stop', 'explode', etc.
>
> I *think* it looks like I might need a listener object added to the handmorph but I don't see how to check if the focus is nil as part of that path. An alternative appears to be something to do with the owner of the hand… maybe?
> I've spent too long wandering a twisty maze of messages and as a result, got eaten by a Grue. Explanations of how this all works would be appreciated, whether actual or pointers to already written doc. For example, why do all the implementors of #handleFocusEvent: except Morph use both #processEvent: and handleEvent: when it looks like #processEvent also sends #handleEvent: ? I hope there are intelligible explanations out there...
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Strange OpCodes: ETO: Emulate Toaster Oven
>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130723/3b5b10f9/attachment.htm


More information about the Squeak-dev mailing list