2017-03-21 20:21 GMT+01:00 Daniel BLANC <daniel.bl...@gmail.com>:

> Hi all,
>
> I'm building a Spec UI with an ImageModel and a LabelModel. The image is a
> map, and the label should display the mouse coordinates when the mouse
> cursor is on the map.
>
> I'm a newcomer to Pharo and Smalltalk, I've searched in the pharo image,
> and looked into events, on:send:to: message, but I don't know how to
> properly use them with Spec.
>
> For testing purpose I've tried just to get a mouse click with this:
>
> MyStuff >> initializeWidgets
> map := self newImage.
> mousePos := self newLabel.
> map on: #click send: #mouseClicked to: self
>
> But that doesn't work. Any idea how I can do this ?
>
> Thanks,
> Daniel
>

Hi Daniel,

I am afraid, mouse move events aren't catched by the image, and therfore
you can not use the image model to listen for the mouse position changes.
The above code for mouse click events does not work, because the click
event is only send to the widget (a ImageMorph) but not to the model.

But the model registers itself for the click event when the widget is
build. If a click even is send on the image morph, the model calls #value
on its action property, just set
an apropiate block as action for your ImageModel

an example:

im := ImageModel new.
im image: PolymorphSystemSettings pharoLogoForm.
im action:[ActiveHand inspect].
im openWithSpec.

clicking on the image will open an inspector with the active hand.

Reply via email to