Image View Events

Hi,

The documentation regarding an Image View states that amongst other events it supports handlers that respond to a clicked event.

I cannot get an image view I have created to respond to a mouse clicked in its area of the screen.

I think I must be missing something, can anyone help.

All the best

–tellboy

tellboy, I’m not sure why that command is even in the docs, but you’re right, it doesn’t work. An image view (a cocoa NSImageView) is a view, not a control, so technically speaking it doesn’t necessarily have to respond to action events. In my opinion, it should respond to mouse events (i.e. mousedown) but for whatever reason this has been disabled in ASS. I think the problem is not that the image view should respond to the clicked event, but rather that it should not be an option in IB and it should be removed from the documentation. Whether the mouse events should be enabled is another story.

A common workaround, is to place a button over the image view and use that to capture your events. Set the button to borderless, and size it the same as your image view, so that it covers it completely. Ultimately, you should be able to configure it so that the user never knows the button is there.

Hope that helps,
j

Using NSbutton class, you can create an image button of any size. It supports everything imageview does, plus mouse over and clicked. I wouldn’t use an image view for something that needs clicked.

Yes, but nsimageview can do some things that a button can not… otherwise you wouldn’t need image views at all.:wink: If the images that tellboy are using are anything but icons for controls or ui elements, chances are he’ll need more flexibility in his image views than an nsbutton can provide. The major drawback to using a button instead of an image view is that a button does not have resizing or scaling capabilities. The button can only (by default) display the image as it is read straight from file. When working with images, it is often more practical to use nsimageview and then accomodate any shortcomings that the class has by either overriding them in a custom subclass, or using a button positioned over it to add functionality.

Hi,

Thanks for all the replies.

jobu is correct in that I need the in built scaling properties of an Image View which in my case is holding images approx. 750 x 550.

The purpose of trying to use the mouse click event was to break out of a loop which displays successive images.

I have previously tried the trick of allocating an escape key to an offscreen button and testing through an idle handler. This works to a point, however, if there is a delay of say 3 seconds between changing the image in the image view then it is necessary to hold the key down for this period otherwise it does not register. I am assuming the idle handler is not called when the delay command is in progress.

Another solution maybe to have a customised delay where the idle handler can be called but I’m not sure how to implement this.

Do you know of any ideas I could try.

Thanks

–tellboy