Re: Finding a view (Cocoa theory)
Re: Finding a view (Cocoa theory)
- Subject: Re: Finding a view (Cocoa theory)
- From: Carl Gieringer <email@hidden>
- Date: Fri, 18 Feb 2005 17:37:11 -0900
(Sorry for sending last email twice; I often forget to include the list
in my replies...)
I see what you mean, now. Look at NSControl's - tag method.
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSControl.html
Although I have not used tags, they appear to be exactly what you need.
You can set the tags programmatically (setTag) or in IB via the
attributes in the inspector. You would need some reference to your
inspector's window, and then you could recursively examine it's
contentView's subviews, seeing if the tag is any particular value that
you set it.
(I am glad that this subject came up; I have a window with which I
could use this tag method to enable/disable controls in it...)
On Feb 18, 2005, at 17:10, mark wrote:
Well, that's my point--I don't see any way in IB to "tag" a view so
that I
can find it when searching (how to find one checkbox vs another or one
NSView vs another NVSView).
What I'm trying to do is build a list of NSViews that contain controls
(text, checkboxes) that I can hide/show/move around in an inspector
window
so that only the panes that have valid properties for a given selected
object are shown (and shown "neatly"). If I could set an "ID" in IB, I
could then look for that ID in my app, building up a list of those
"special"
views. It looks like I can either ref those views via outlets or
create a
subclass of NSView that supports IDs. For the amount of work, outlets
seem
to be the way to go…
Thanks,
Mark
From: Carl Gieringer <email@hidden>
Date: Fri, 18 Feb 2005 17:02:55 -0900
To: Mark Dawson <email@hidden>
Subject: Re: Finding a view (Cocoa theory)
Hi,
I am a little confused by your question: from any spot in the view
hierarchy, what other view would you be looking for? How would you
know if you had found it? E.g., if you would be looking for a view
via
a "unique ID", how would your original view get the id in the first
place, and if it got the id at some point in a program, couldn't it
just as easily have gotten a reference to the view?
Maybe these methods are of use?
NSView:
- ancestorSharedWithView:
- isDescendantOf:
NSWindow:
- windowNumber
Also check the function NSWindowList at:
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Functions/AppKitFunctions.html
This mentions NSConvertWindowNumberToGlobal:
http://www.toodarkpark.org/computers/objc/AppKit/Functions/
AppKitFunctions.html
Lastly some window server/NSApp reference:
http://www.oreilly.com/catalog/learncocoa/chapter/ch06.html
On Feb 18, 2005, at 16:00, Mark Dawson wrote:
Does Cocoa allow finding an NSView? From what I can tell, there
isn't
any unique ID for a view, so from any spot in a view hierarchy, it
doesn't seem programatically possible to find a view that's either a
sibling, super, or sub view from any particular view. Is that
correct? So, if you want to use any particular view, you need to set
it up as an outlet, correct?
Thanks,
Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden