Simulator window and halos

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Simulator window and halos

Eliot Miranda-2
 
Hi All,

    I've finally found time to look at Timothy's event handling stuff for the simulator.  I've adapted hist code to a more minimal route, but thanks to him (thanks Timothy!)  I'm able to evaluate 3+4 through the UI.  But what I can't do is suppress halos appearing on the simulator window when I press a mouse button that brings up halos in the host (but may not in the simulated image because their mouse button swapping preference may be different) when in the bitmap display view.

My question is how to suppress it.  I see that wantsHalo is a likely method on Morph.  But if I change the single sender (Morph>>handleMouseEnter:) to ignore it I still get halos.  So I don't understand how halos appear in response to a mouse click.  hat's the chain of effect?

To suppress halos, is there something I can do locally in the ImageMorph displaying the bitmap (or in a subclass, e.g. NoHaloImageMorph)  or do I need to have a special SystemWindow?
--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

KenDickey
 
On Wed, 15 Jul 2015 00:27:38 -0700
Eliot Miranda <[hidden email]> wrote:

What if you comment our
        HandMorph>>spawnMagicHaloFor:
?

-KenD
-KenD
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Chris Muller-3
In reply to this post by Eliot Miranda-2

> My question is how to suppress it.  I see that wantsHalo is a likely method on Morph.  But if I change the single sender (Morph>>handleMouseEnter:) to ignore it I still get halos.  So I don't understand how halos appear in response to a mouse click.  hat's the chain of effect?

I answer this type of UI questions by capturing "thisContext
longStack" into a global variable.

    Smalltalk at: #X put: OrderedCollection new

then, at the top of addHalo:

     X add: thisContext longStack

HTH.
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Karl Ramberg
In reply to this post by Eliot Miranda-2
 
A few suggestions:
Make sure these preferences are off: maintainHalos, magicHalos  and mouseOverHalos 

Call chain in Morph to get the halo is 
Morph>>handleMouseDown: 
Morph>>blueButtonDown: 
Morph>>addHalo:
HandMorph>>popUpFor:  event: 

Karl







On Wed, Jul 15, 2015 at 9:27 AM, Eliot Miranda <[hidden email]> wrote:
 
Hi All,

    I've finally found time to look at Timothy's event handling stuff for the simulator.  I've adapted hist code to a more minimal route, but thanks to him (thanks Timothy!)  I'm able to evaluate 3+4 through the UI.  But what I can't do is suppress halos appearing on the simulator window when I press a mouse button that brings up halos in the host (but may not in the simulated image because their mouse button swapping preference may be different) when in the bitmap display view.

My question is how to suppress it.  I see that wantsHalo is a likely method on Morph.  But if I change the single sender (Morph>>handleMouseEnter:) to ignore it I still get halos.  So I don't understand how halos appear in response to a mouse click.  hat's the chain of effect?

To suppress halos, is there something I can do locally in the ImageMorph displaying the bitmap (or in a subclass, e.g. NoHaloImageMorph)  or do I need to have a special SystemWindow?
--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Bert Freudenberg
 
In the Etoys image we changed wantsHaloFromClick to

wantsHaloFromClick
        ^ self valueOfProperty: #wantsHaloFromClick ifAbsent: [^true].

With that you could just set the property. Without that, you would have to override the method.

- Bert -

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Eliot Miranda-2
 


On Wed, Jul 15, 2015 at 1:11 PM, Bert Freudenberg <[hidden email]> wrote:
 
In the Etoys image we changed wantsHaloFromClick to

wantsHaloFromClick
        ^ self valueOfProperty: #wantsHaloFromClick ifAbsent: [^true].

With that you could just set the property. Without that, you would have to override the method.

- Bert -

I'm pretty sure now that what I have to do is implement handlerForBlueButtonDown: in my subclass of ImageMorph so that it forwards the event directly to the simulator instead of passing it up.  The problems with the wantsHaloFromClick approaches are that they either require some special setting, which the user may not know to apply, or that the effect of the setting is merely to turn off halos on that submorph, but not on the enclosing window.

--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Eliot Miranda-2
 
Hi All,

   ah, it works :-).  I can now do 3+4 via command/option p, and bring up halos and translate.


The code in question is, first in [Foo]Simulator>>openAsMorph[NoTranscript] to do

window addMorph: (displayView := SimulatorImageMorph new image: displayForm)
frame: (0@0 corner: 1@0.8).
displayView activeHand addEventListener: self.
eventTransformer := SimulatorEventTransformer new.

and then

StackInterpreterSimulator>>handleListenEvent: aMorphicEvent
"openAsMorph[NoTranscript] regsitered me for listen events via HandMorph>>addEventListener.
Transform the listen event and add it to my event queue."

((aMorphicEvent isMouse or: [aMorphicEvent isKeyboard])
and: [displayView bounds containsPoint: aMorphicEvent position]) ifTrue:
[eventTransformer degenerateEvent: aMorphicEvent for: self]

and

Object subclass: #SimulatorEventTransformer
instanceVariableNames: 'buttons modifiers'
classVariableNames: ''
poolDictionaries: 'EventSensorConstants'
category: 'VMMaker-InterpreterSimulation-Morphic'

degenerateEvent: aMorphicEvent for: client
"Handle ''degenerating'' events for aClient.  This interface gets the client
to queue the event via queueForwardedEvent:, and may generate more
than one event for the input event (i.e. a fake mouse move before a
button down), in addition to filtering-out excessive mouse moves."

aMorphicEvent isMouse ifTrue:
[^self degenerateMouseEvent: aMorphicEvent for: client].
aMorphicEvent isKeyboard ifTrue:
[^self degenerateKeyboardEvent: aMorphicEvent for: client].
^self degenerateUnknownEvent: aMorphicEvent for: client

degenerateKeyboardEvent: aMorphicEvent for: aClient
"Convert the keyboard event into a low-level event for the VM simulator (aClient).
See HandMorph>>generateKeyboardEvent and EventSensor class comment"

aClient queueForwardedEvent:
{ 2.
aMorphicEvent timeStamp.
aMorphicEvent keyValue. "<--this is wrong. See Sensor FirstEvt: for what needs to happen. hooo boy"
aMorphicEvent type caseOf: {
[#keyDown] -> [EventKeyDown].
[#keyUp] -> [EventKeyUp].
[#keystroke] -> [EventKeyChar] }.
modifiers.
aMorphicEvent keyValue.
0.
self windowIndex }

degenerateMouseEvent: aMorphicEvent for: aClient
"Convert the mouse event into low-level events for the VM simulator (aClient).  Filter-out mouse moves,
and generate a fake mouse move before each button press.
See HandMorph>>generateMouseEvent"
| translated |
translated := aMorphicEvent position - aClient displayView bounds origin.
modifiers := aMorphicEvent buttons >> 3. "Sad, but modifiers come in on mouse move events..."

aMorphicEvent type == #mouseMove
ifTrue: "filter-out mouse moves unless buttons are pressed, so simulation doersn't get window leave events when we leave its window"
[buttons = 0 ifTrue: [^nil]]
ifFalse:"If the buttons are going down, make sure to add a mouse move event to the current position before the buttons are pressed."
[((buttons bitAnd: 7) = 0 and: [(aMorphicEvent buttons bitAnd: 7) ~= 0]) ifTrue:
[aClient queueForwardedEvent:
{ 1.
aMorphicEvent timeStamp.
translated x.
translated y.
0.
buttons >> 3.     "Thanks dtl"
0.
self windowIndex }].
buttons := aMorphicEvent buttons].
aClient queueForwardedEvent:
{ 1.
aMorphicEvent timeStamp.
translated x.
translated y.
buttons bitAnd: 7.  "thanks Ron T."
buttons >> 3.     "Thanks dtl"
0.
self windowIndex }

windowIndex
^1

and the key to catching all events without interpretation within the displayView is

ImageMorph subclass: #SimulatorImageMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'VMMaker-InterpreterSimulation-Morphic'

handleMouseDown: anEvent
anEvent wasHandled: true

handleMouseEnter: anEvent
anEvent wasHandled: true

handleMouseLeave: anEvent
^super handleMouseLeave: anEvent

handleMouseOver: anEvent
anEvent wasHandled: true

handleMouseUp: anEvent
anEvent wasHandled: true

handlerForMouseDown: anEvent
"Override all mouse button shenanigans like halos by handling all mouse down events."
^self


Huge thanks for Timothy for getting this started.  I would have never got it working but for that work.  Thanks.

On Wed, Jul 15, 2015 at 1:15 PM, Eliot Miranda <[hidden email]> wrote:


On Wed, Jul 15, 2015 at 1:11 PM, Bert Freudenberg <[hidden email]> wrote:
 
In the Etoys image we changed wantsHaloFromClick to

wantsHaloFromClick
        ^ self valueOfProperty: #wantsHaloFromClick ifAbsent: [^true].

With that you could just set the property. Without that, you would have to override the method.

- Bert -

I'm pretty sure now that what I have to do is implement handlerForBlueButtonDown: in my subclass of ImageMorph so that it forwards the event directly to the simulator instead of passing it up.  The problems with the wantsHaloFromClick approaches are that they either require some special setting, which the user may not know to apply, or that the effect of the setting is merely to turn off halos on that submorph, but not on the enclosing window.

--
best,
Eliot



--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Eliot Miranda-2
 
and I was going to post an image of the simulator window rotated to bring the rotated workspace back level, but exporting is done irrespective of the window's current rotation :-(.  But there's screen grab ;-) :


_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Simulator window and halos

Bert Freudenberg
In reply to this post by Eliot Miranda-2
 
"Degenerate", haha ;)

Great!

- Bert -

On 15.07.2015, at 15:08, Eliot Miranda <[hidden email]> wrote:

Hi All,

   ah, it works :-).  I can now do 3+4 via command/option p, and bring up halos and translate.

<Simulation of trunk46-spur.image.png>

The code in question is, first in [Foo]Simulator>>openAsMorph[NoTranscript] to do

window addMorph: (displayView := SimulatorImageMorph new image: displayForm)
frame: (0@0 corner: 1@0.8).
displayView activeHand addEventListener: self.
eventTransformer := SimulatorEventTransformer new.

and then

StackInterpreterSimulator>>handleListenEvent: aMorphicEvent
"openAsMorph[NoTranscript] regsitered me for listen events via HandMorph>>addEventListener.
Transform the listen event and add it to my event queue."

((aMorphicEvent isMouse or: [aMorphicEvent isKeyboard])
and: [displayView bounds containsPoint: aMorphicEvent position]) ifTrue:
[eventTransformer degenerateEvent: aMorphicEvent for: self]

and

Object subclass: #SimulatorEventTransformer
instanceVariableNames: 'buttons modifiers'
classVariableNames: ''
poolDictionaries: 'EventSensorConstants'
category: 'VMMaker-InterpreterSimulation-Morphic'

degenerateEvent: aMorphicEvent for: client
"Handle ''degenerating'' events for aClient.  This interface gets the client
to queue the event via queueForwardedEvent:, and may generate more
than one event for the input event (i.e. a fake mouse move before a
button down), in addition to filtering-out excessive mouse moves."

aMorphicEvent isMouse ifTrue:
[^self degenerateMouseEvent: aMorphicEvent for: client].
aMorphicEvent isKeyboard ifTrue:
[^self degenerateKeyboardEvent: aMorphicEvent for: client].
^self degenerateUnknownEvent: aMorphicEvent for: client

degenerateKeyboardEvent: aMorphicEvent for: aClient
"Convert the keyboard event into a low-level event for the VM simulator (aClient).
See HandMorph>>generateKeyboardEvent and EventSensor class comment"

aClient queueForwardedEvent:
{ 2.
aMorphicEvent timeStamp.
aMorphicEvent keyValue. "<--this is wrong. See Sensor FirstEvt: for what needs to happen. hooo boy"
aMorphicEvent type caseOf: {
[#keyDown] -> [EventKeyDown].
[#keyUp] -> [EventKeyUp].
[#keystroke] -> [EventKeyChar] }.
modifiers.
aMorphicEvent keyValue.
0.
self windowIndex }

degenerateMouseEvent: aMorphicEvent for: aClient
"Convert the mouse event into low-level events for the VM simulator (aClient).  Filter-out mouse moves,
and generate a fake mouse move before each button press.
See HandMorph>>generateMouseEvent"
| translated |
translated := aMorphicEvent position - aClient displayView bounds origin.
modifiers := aMorphicEvent buttons >> 3. "Sad, but modifiers come in on mouse move events..."

aMorphicEvent type == #mouseMove
ifTrue: "filter-out mouse moves unless buttons are pressed, so simulation doersn't get window leave events when we leave its window"
[buttons = 0 ifTrue: [^nil]]
ifFalse:"If the buttons are going down, make sure to add a mouse move event to the current position before the buttons are pressed."
[((buttons bitAnd: 7) = 0 and: [(aMorphicEvent buttons bitAnd: 7) ~= 0]) ifTrue:
[aClient queueForwardedEvent:
{ 1.
aMorphicEvent timeStamp.
translated x.
translated y.
0.
buttons >> 3.     "Thanks dtl"
0.
self windowIndex }].
buttons := aMorphicEvent buttons].
aClient queueForwardedEvent:
{ 1.
aMorphicEvent timeStamp.
translated x.
translated y.
buttons bitAnd: 7.  "thanks Ron T."
buttons >> 3.     "Thanks dtl"
0.
self windowIndex }

windowIndex
^1

and the key to catching all events without interpretation within the displayView is

ImageMorph subclass: #SimulatorImageMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'VMMaker-InterpreterSimulation-Morphic'

handleMouseDown: anEvent
anEvent wasHandled: true

handleMouseEnter: anEvent
anEvent wasHandled: true

handleMouseLeave: anEvent
^super handleMouseLeave: anEvent

handleMouseOver: anEvent
anEvent wasHandled: true

handleMouseUp: anEvent
anEvent wasHandled: true

handlerForMouseDown: anEvent
"Override all mouse button shenanigans like halos by handling all mouse down events."
^self


Huge thanks for Timothy for getting this started.  I would have never got it working but for that work.  Thanks.

On Wed, Jul 15, 2015 at 1:15 PM, Eliot Miranda <[hidden email]> wrote:


On Wed, Jul 15, 2015 at 1:11 PM, Bert Freudenberg <[hidden email]> wrote:
 
In the Etoys image we changed wantsHaloFromClick to

wantsHaloFromClick
        ^ self valueOfProperty: #wantsHaloFromClick ifAbsent: [^true].

With that you could just set the property. Without that, you would have to override the method.

- Bert -

I'm pretty sure now that what I have to do is implement handlerForBlueButtonDown: in my subclass of ImageMorph so that it forwards the event directly to the simulator instead of passing it up.  The problems with the wantsHaloFromClick approaches are that they either require some special setting, which the user may not know to apply, or that the effect of the setting is merely to turn off halos on that submorph, but not on the enclosing window.

--
best,
Eliot



--
best,
Eliot

smime.p7s (8K) Download Attachment