Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-10087

OSX: facilitate easy preferences menu item handling

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Master
    • Fix Version/s: 4.0.0
    • Component/s: cordova-osx
    • Labels:
      None

      Description

      currently it is not easy possible to capture the applications preferences menu item, except via the title, which is a bit unstable.

      either we define a tag value or a predefined action selector that can be detected. for example:

      - (void) pluginInitialize {
          [super pluginInitialize];
      
          NSMenu* appMenu = self.viewController.window.menu;
          NSMenu* mainMenu = [appMenu itemAtIndex:0].submenu;
      
          bool found = false;
          for (NSMenuItem* item in mainMenu.itemArray) {
              if (item.action == @selector(onPreferences:)) {
                  // we simply adjust the target for the preferences menu item to this plugin instance
                  item.target = self;
                  found = true;
                  break;
              }
          }
      
          if (!found) {
              NSLog(@"Warning, didn't find preferences menu item.");
          }
      }
      
      - (IBAction) onPreferences:(id) sender {
          NSLog(@"onPreferences...");
      }
      
      

        Attachments

          Activity

            People

            • Assignee:
              tripod Tobias Bocanegra
              Reporter:
              tripod Tobias Bocanegra
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: