# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1325173242 0 # Node ID 6506f29dfefca7028172588fa66a52f55ed183ac # Parent 03c0eca3aaba56662b5a05799022d67211fd44e3 Implement automatic checking and unchecking of menu items on Mac. This was overlooked because I typically set the state in the app. diff -r 03c0eca3aaba -r 6506f29dfefc mac/dw.m --- a/mac/dw.m Thu Dec 29 14:39:58 2011 +0000 +++ b/mac/dw.m Thu Dec 29 15:40:42 2011 +0000 @@ -511,6 +511,15 @@ -(void)doFlush:(id)param; @end +@interface DWMenuItem : NSMenuItem +{ + int check; +} +-(void)setCheck:(int)input; +-(int)check; +-(void)dealloc; +@end + @implementation DWObject -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } -(void)synchronizeThread:(id)param @@ -522,6 +531,14 @@ } -(void)menuHandler:(id)param { + DWMenuItem *item = param; + if([item check]) + { + if([item state] == NSOnState) + [item setState:NSOffState]; + else + [item setState:NSOnState]; + } _event_handler(param, nil, 8); } -(void)doBitBlt:(id)param @@ -979,11 +996,9 @@ @end /* Subclass for a menu item type */ -@interface DWMenuItem : NSMenuItem { } --(void)dealloc; -@end - @implementation DWMenuItem +-(void)setCheck:(int)input { check = input; } +-(int)check { return check; } -(void)dealloc { dw_signal_disconnect_by_window(self); [super dealloc]; } @end @@ -7218,9 +7233,13 @@ [menu addItem:item]; [item setTag:itemid]; - if(flags & DW_MIS_CHECKED) - { - [item setState:NSOnState]; + if(check) + { + [item setCheck:YES]; + if(flags & DW_MIS_CHECKED) + { + [item setState:NSOnState]; + } } if(flags & DW_MIS_DISABLED) {