changeset 1517:6506f29dfefc

Implement automatic checking and unchecking of menu items on Mac. This was overlooked because I typically set the state in the app.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 29 Dec 2011 15:40:42 +0000
parents 03c0eca3aaba
children bd538277e1e8
files mac/dw.m
diffstat 1 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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)
         {