[Drawkit] validateMenuItem:

V1ru8 info at v1ru8.net
Tue Jun 23 07:05:30 PDT 2009


Hi Graham,

This is my method:

@interface MyDKViewController : DKViewController {

}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
@end
@implementation MyDKViewController
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
     NSLog(@"- (BOOL)validateMenuItem:(NSMenuItem *)menuItem");
     return TRUE;
}

@end

That should enable all menu items right?

To use this controller I set it in the -  
(void)windowControllerDidLoadNib:(NSWindowController *) aController  
method of my subclass of DKDrawingDocument.

  DKDrawingView *view = [self mainView];
     DKViewController *controller = [[MyDKViewController alloc]  
initWithView:view];
     [view setController:controller];

Maybe thats the  wrong way? (maybe I really oversee something very  
dump here... :-/)

If I don't set my own controller and add the following breakpoint:  - 
[DKViewController validateMenuItem:] it breaks when I access a menu.


Regards,
Thomas
On 23.06.2009, at 13:52, Graham Cox wrote:

>
> On 23/06/2009, at 9:42 PM, V1ru8 wrote:
>
>> It's me again and again I have problems putting my head around  
>> DrawKit.
>> I'm trying to add some MenuItems on a Document based Application.  
>> So I stared writing the validateMenuItem method for my MenuItem. I  
>> placed it in my subclass of the DKViewController. I also tried it  
>> in my subclass of the DKDrawingDocument but it gets never called. I  
>> read the "BuIlt-in commands and features" part of the "Programmers  
>> Reference" but I don't get it what I'm doing wrong. Can you help me?
>
>
> Hi Thomas,
>
> It's a bit hard to say what the problem might be from your  
> description. Overriding it in a view controller and/or the document  
> should work. Are you sure you have it exactly correctly spelt and  
> with the same type for its argument and return type?
>
> The flow of control of this method in DK is as follows:
>
> view (first responder) -> its controller -> active layer -> selected  
> object(s)
>                      |-> (responder chain) -> document -> app...
>
> the second path is only followed if nothing in the first path  
> validates the item.
>
> --Graham
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net



More information about the Drawkit mailing list