Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom hiview in NIB and Leopard



If I understand Eric correctly, then the issue is not related to CreateWindowFromNib, but related to when your code calls:
CreateNibReferenceWithCFBundle(bundle, kMainNibFileName, &sNib);
You need to register your class before that call (this is the scenario that I verified)


Jesper

On Nov 2, 2007, at 8:42 AM, Chinh Nguyen wrote:


On Nov 1, 2007, at 6:54 PM, Eric Schlegel wrote:


On Nov 1, 2007, at 9:52 AM, Chinh Nguyen wrote:

I've got a custom hiview in a window stored in a NIB. The custom hiview is embedded in just the content hiview of the window. I HIObjectRegisterSubclass(myclassid, kHIViewClassID, ...), then load the NIB. In Tiger, my construct proc/event handler is called correctly. In Leopard, the construct proc/event handler is never called. On Tiger, I'm using Xcode 2.4.1; Xcode 3.0 on Leopard. The Leopard install is a fresh install (not an upgrade).

I debugged this using a sample app that Jesper provided and it looks like this will happen if you're loading the nib file that specifies the custom class ID before you actually register that class. This used to work, but in Leopard we go down a different path if the class isn't already registered and wind up creating a generic HIObject rather than an instance of your class. That's a bug, and I'll fix it, hopefully for a Leopard software update. However, until then, I think you can work around this by registering your custom classes before loading your nib file. Please try that and let me know whether it works for you.


But I am already doing a HIObjectRegisterSubclass() first then loading the nib.

	static HIObjectClassRef	theClass = NULL ;

	if (theClass==NULL) {
		status = HIObjectRegisterSubclass(myviewclassid,
			kHIViewClassID, 0, myviewhandler,
			GetEventTypeCount(eventType), eventType, 0, &theClass) ;
		require_noerr(status, exitRegisterClass) ;
	}

	status = CreateWindowFromNib(nibRef, CFSTR("mywindow"), &window) ;

Is there more to it than this?  Again, this works in Tiger.

I verified that I'm not mistakenly loading the window early elsewhere either. If there's sample code out there that does this, I'm more than happy to study it. Otherwise, I'll just create the custom view at runtime.

-Chinh Nguyen
email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >custom hiview in NIB and Leopard (From: Chinh Nguyen <email@hidden>)
 >Re: custom hiview in NIB and Leopard (From: Eric Schlegel <email@hidden>)
 >Re: custom hiview in NIB and Leopard (From: Chinh Nguyen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.