FROM : Wilhelm Phillips
DATE : Mon Oct 18 20:29:11 2004
Thanks Brendan,
That example was exactly what I needed. I was a little confused about
the need for the separate function and how to set it up.
Though I do know the desired order of the subviews, for some reason
they are arbitrarily ordered on build. I layer them in the desired
order in IB - (an unbordered NSPopupButton directly overlapping an
NSImage), but they don't appear in the same order when I build. This
strangeness may be caused by my main custom NSView. Using the
sortSubviewsUsingFunction works perfectly to ensure the correct order
of the subviews. I believe I read in the archives a couple of others
having the same ordering issues with overlapping subviews.
And thanks for your comments on properly describing problems.
Will
On Oct 17, 2004, at 5:37 PM, Brendan Younger wrote:
> sortSubviewsUsingFunction: takes a function as a parameter, not just a
> list of parameters. Here's how to call it:
>
> int my_great_sorting_function(id view1, id view2, void* context) {
> // do some wonderful sorting here and return NSOrderedAscending or
> NSOrderedDescending
> }
>
> // Later on....
>
> [mainView sortSubviewsUsingFunction:my_great_sorting_function
> context:nil];
>
> That should work. Note how the parameter list for
> my_great_sorting_function() matches the definition of
> sortSubviewsUsingFunction. Also, you shouldn't say "crashes" to
> describe compiling problems. Crashing is when the running application
> quits unexpectedly, whereas failing to compile is a different problem.
> However, since you obviously already know the order of the views, you
> can simply place them into mainView in the correct order the first
> time.
>
> Brendan Younger
DATE : Mon Oct 18 20:29:11 2004
Thanks Brendan,
That example was exactly what I needed. I was a little confused about
the need for the separate function and how to set it up.
Though I do know the desired order of the subviews, for some reason
they are arbitrarily ordered on build. I layer them in the desired
order in IB - (an unbordered NSPopupButton directly overlapping an
NSImage), but they don't appear in the same order when I build. This
strangeness may be caused by my main custom NSView. Using the
sortSubviewsUsingFunction works perfectly to ensure the correct order
of the subviews. I believe I read in the archives a couple of others
having the same ordering issues with overlapping subviews.
And thanks for your comments on properly describing problems.
Will
On Oct 17, 2004, at 5:37 PM, Brendan Younger wrote:
> sortSubviewsUsingFunction: takes a function as a parameter, not just a
> list of parameters. Here's how to call it:
>
> int my_great_sorting_function(id view1, id view2, void* context) {
> // do some wonderful sorting here and return NSOrderedAscending or
> NSOrderedDescending
> }
>
> // Later on....
>
> [mainView sortSubviewsUsingFunction:my_great_sorting_function
> context:nil];
>
> That should work. Note how the parameter list for
> my_great_sorting_function() matches the definition of
> sortSubviewsUsingFunction. Also, you shouldn't say "crashes" to
> describe compiling problems. Crashing is when the running application
> quits unexpectedly, whereas failing to compile is a different problem.
> However, since you obviously already know the order of the views, you
> can simply place them into mainView in the correct order the first
> time.
>
> Brendan Younger
| Related mails | Author | Date |
|---|---|---|
| Wilhelm Phillips | Oct 17, 23:04 | |
| Louis C. Sacha | Oct 18, 09:09 | |
| Wilhelm Phillips | Oct 18, 20:27 | |
| Wilhelm Phillips | Oct 18, 20:29 |






Cocoa mail archive

