Hi,

I have a layer-hosted view containing several layers making up the UI of my application. In a few cases, I would actually like to use standard controls *inside* of this layer-hosted view. For example, I'd like to have a standard NSButton in one location, and use an NSTextField to edit some text in another location.

What I've done until now is to create the NSButton/NSTextField in the standard way, then add them as sub-views of my main view. Once this is done, I obtain the "layer" property of those objects and manipulate this layer like the other ones, to position them, set their z- position, hide or show them, and so on.

This seems to work relatively well, except that the NSButton instance does not react to mouse events. For example, it does not perform the action or toggle its state when I click on it. Instead, my layer- hosted view gets the event (i.e. its mouseDown: method gets invoked). I found a partial work-around, which consists in calling "performClick:" on the button whenever its layer is the one under the mouse when the click happens, but this is not satisfactory (e.g. the button does not highlight when the mouse hovers over it, even though it should, given how it's configured).

So I have two questions:

1. Is it actually valid to add an NSButton or NSTextField as a sub- view of a layer-hosted view?

2a. If it is, then how do I make sure the NSButton I add reacts to mouse events as it should?

2b. If it isn't, then is there a better way to do what I'm trying to do, i.e. have a view containing many many layers managed directly by my application, with a few standard controls mixed in?

Thanks,
Michel.
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to