[squeak-dev] continuous display of cursor position

H. Hirzel hannes.hirzel at gmail.com
Fri Jan 4 23:33:14 UTC 2013


Ken,

It seems that Edgar's fileIn code is corrupted.

Here is a modified version which works for me
------------------------------------------------------------------------------------



'From Squeak4.2 of 13 June 2011 [latest update: #11599] on 16 April
2012 at 9:31 am'!
StringMorph subclass: #InfoMorph
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'HJHWork2013'!


!InfoMorph methodsFor: 'step' stamp: 'edc 5/12/2005 16:06'!
step
	| pt |
	super step.
	pt := Sensor peekMousePt.
      self contents: pt asString.
! !

!InfoMorph methodsFor: 'step' stamp: 'edc 2/20/2002 11:30'!
stepTime
	"Answer the desired time between steps in milliseconds."

	^ 100! !




------------------------------------------------------------------------------------



Then evaluate

InfoMorph new openInWorld



HTH


HJH

On 1/4/13, Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com> wrote:
> Why open a class ?
>
> 2013/1/4 Ken G. Brown <kbrown at mac.com>:
>>
>> On 2013-01-04, at 1:57 AM, Edgar J. De Cleene wrote:
>>
>>>
>>>
>>>
>>> On 1/3/13 11:50 PM, "Ralph Boland" <rpboland at gmail.com> wrote:
>>>
>>>> I would like to create a small TextMorph that continuously displays the
>>>> position
>>>> of the cursor.  To do this I need to write something of the form:
>>>>
>>>> true whileTrue: [
>>>>    x := self getCursorPosition.
>>>>    textMorph display: x.
>>>>    self sleep:  10   "milliseconds"]
>>>>
>>>> I plan to use this when investigating some morph that is not displaying
>>>> the
>>>> way
>>>> I expect it to.
>>>>
>>>> Can someone provide me with hints as how to properly do this or point
>>>> me to a package that already does this or something similar?
>>>>
>>>> I have searched the code and the Internet.  I found that
>>>> "getCursorPosition"
>>>> can be implemented as:
>>>>
>>>>     "World activeHand position"
>>>>
>>>> I can also figure out how to build the Morph I need to display the
>>>> Cursor position.
>>>>
>>>> I don't know how to implement "sleep:"
>>>> I am not sure if I should use an infinite loop as I have.
>>>>
>>>> An alternative to the TextMorph I want is to construct a cursor that
>>>> continuously displays its
>>>> position but I prefer my original plan.
>>>>
>>>> Any help much appreciated.
>>>>
>>>> Ralph Boland
>>>>
>>>
>>> See the attached, I use daily
>>>
>>> Evaluate InfoMorph openInWorld or InfoMorph openInHand
>>>
>>> Cheers
>>>
>>> Edgar
>>
>> Have you been able to run this in the latest Squeak4.4-12327 on Cog 2640?
>> On my Mac, InfoMorph openInWorld fails:
>>
>> InfoMorph class(Object)>>doesNotUnderstand: #openInWorld
>>         Receiver: InfoMorph
>>         Arguments and temporary variables:
>>                 aMessage:       openInWorld
>>                 exception:      MessageNotUnderstood: InfoMorph
>> class>>openInWorld
>>                 resumeValue:    nil
>>         Receiver's instance variables:
>>                 superclass:     StringMorph
>>                 methodDict:     a
>> MethodDictionary(#cambio:->(InfoMorph>>#cambio: "a
>> CompiledMethod...etc...
>>                 format:         150
>>                 instanceVariables:      nil
>>                 organization:   ('step' step stepTime)
>> ('as yet unclassified' cambio:)
>>
>>                 subclasses:     nil
>>                 name:   #InfoMorph
>>                 classPool:      nil
>>                 sharedPools:    nil
>>                 environment:    Smalltalk globals "a SystemDictionary with
>> lots of globals"
>>                 category:       #SqueakRos
>>
>> Ken G. Brown
>>
>>
>>>
>> [see attached file: InfoMorph.st]
>>
>>
>>
>
>


More information about the Squeak-dev mailing list