comparison ios/dw.m @ 2601:3201f9e9067b

iOS: Actually implement disabled menu items using UIMenuElementAttributesDisabled. I added setEnabled method to the DWMenuItem class, but it previously just stored the value and didn't actually disable or enable the items.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 11 Jul 2021 21:08:36 +0000
parents 0bb974e70435
children cc5013e626f7
comparison
equal deleted inserted replaced
2600:0bb974e70435 2601:3201f9e9067b
1522 @end 1522 @end
1523 1523
1524 /* Subclass for a menu item type */ 1524 /* Subclass for a menu item type */
1525 @implementation DWMenuItem 1525 @implementation DWMenuItem
1526 -(void)setCheck:(BOOL)input { check = input; } 1526 -(void)setCheck:(BOOL)input { check = input; }
1527 -(void)setEnabled:(BOOL)input { enabled = input; } 1527 -(void)setEnabled:(BOOL)input { enabled = input; [self setAttributes:(enabled ? 0 : UIMenuElementAttributesDisabled)]; }
1528 -(void)setSubmenu:(DWMenu *)input { submenu = input; } 1528 -(void)setSubmenu:(DWMenu *)input { submenu = input; }
1529 -(void)setMenu:(DWMenu *)input { menu = input; } 1529 -(void)setMenu:(DWMenu *)input { menu = input; }
1530 -(void)setTag:(unsigned long)input { tag = input; } 1530 -(void)setTag:(unsigned long)input { tag = input; }
1531 -(BOOL)check { return check; } 1531 -(BOOL)check { return check; }
1532 -(BOOL)enabled { return enabled; } 1532 -(BOOL)enabled { return enabled; }
7618 free(newtitle); 7618 free(newtitle);
7619 7619
7620 item = [[DWMenuItem commandWithTitle:nstr image:nil 7620 item = [[DWMenuItem commandWithTitle:nstr image:nil
7621 action:@selector(menuHandler:) 7621 action:@selector(menuHandler:)
7622 propertyList:nil] autorelease]; 7622 propertyList:nil] autorelease];
7623 [item setTag:itemid]; 7623 if(itemid != DW_MENU_AUTO && itemid != DW_MENU_POPUP)
7624 [item setTag:itemid];
7624 [menu addItem:item]; 7625 [menu addItem:item];
7625 7626
7626 if(check) 7627 if(check)
7627 { 7628 {
7628 [item setCheck:YES]; 7629 [item setCheck:YES];
7708 } 7709 }
7709 else if(state & DW_MIS_UNCHECKED) 7710 else if(state & DW_MIS_UNCHECKED)
7710 { 7711 {
7711 [menuitem setState:UIMenuElementStateOff]; 7712 [menuitem setState:UIMenuElementStateOff];
7712 } 7713 }
7713 #if 0 /* TODO: Disabled items not supported on iOS */
7714 if(state & DW_MIS_ENABLED) 7714 if(state & DW_MIS_ENABLED)
7715 { 7715 {
7716 [menuitem setEnabled:YES]; 7716 [menuitem setEnabled:YES];
7717 } 7717 }
7718 else if(state & DW_MIS_DISABLED) 7718 else if(state & DW_MIS_DISABLED)
7719 { 7719 {
7720 [menuitem setEnabled:NO]; 7720 [menuitem setEnabled:NO];
7721 } 7721 }
7722 #endif
7723 } 7722 }
7724 } 7723 }
7725 7724
7726 /* Gets the notebook page from associated ID */ 7725 /* Gets the notebook page from associated ID */
7727 DWNotebookPage *_dw_notepage_from_id(DWNotebook *notebook, unsigned long pageid) 7726 DWNotebookPage *_dw_notepage_from_id(DWNotebook *notebook, unsigned long pageid)
8195 if(style & DW_MIS_CHECKED) 8194 if(style & DW_MIS_CHECKED)
8196 [menuitem setState:UIMenuElementStateOn]; 8195 [menuitem setState:UIMenuElementStateOn];
8197 else if(style & DW_MIS_UNCHECKED) 8196 else if(style & DW_MIS_UNCHECKED)
8198 [menuitem setState:UIMenuElementStateOff]; 8197 [menuitem setState:UIMenuElementStateOff];
8199 } 8198 }
8200 #if 0 /* Disabled menu items not available on iOS currently */
8201 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED)) 8199 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
8202 { 8200 {
8203 if(style & DW_MIS_ENABLED) 8201 if(style & DW_MIS_ENABLED)
8204 [menuitem setEnabled:YES]; 8202 [menuitem setEnabled:YES];
8205 else if(style & DW_MIS_DISABLED) 8203 else if(style & DW_MIS_DISABLED)
8206 [menuitem setEnabled:NO]; 8204 [menuitem setEnabled:NO];
8207 } 8205 }
8208 #endif
8209 } 8206 }
8210 DW_FUNCTION_RETURN_NOTHING; 8207 DW_FUNCTION_RETURN_NOTHING;
8211 } 8208 }
8212 8209
8213 /* 8210 /*