当前位置: 首页>>代码示例>>C#>>正文


C# NSObject.respondsToSelector方法代码示例

本文整理汇总了C#中MObjc.NSObject.respondsToSelector方法的典型用法代码示例。如果您正苦于以下问题:C# NSObject.respondsToSelector方法的具体用法?C# NSObject.respondsToSelector怎么用?C# NSObject.respondsToSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MObjc.NSObject的用法示例。


在下文中一共展示了NSObject.respondsToSelector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: validateUserInterfaceItem

        public bool validateUserInterfaceItem(NSObject sender)
        {
            bool enabled = false;

            Selector sel = (Selector) sender.Call("action");
            if (sel.Name == "sortByName:")
            {
                enabled = true;
                if (sender.respondsToSelector("setState:"))
                    sender.Call("setState:", m_sortByDate ? 0 : 1);
            }
            else if (sel.Name == "sortByDate:")
            {
                enabled = true;
                if (sender.respondsToSelector("setState:"))
                    sender.Call("setState:", m_sortByDate ? 1 : 0);
            }
            else if (sel.Name == "openWithFinder:" || sel.Name == "showInFinder:")
            {
                enabled = m_table.numberOfSelectedRows() > 0;
            }
            else if (respondsToSelector(sel))
            {
                enabled = true;
            }
            else if (SuperCall(NSWindowController.Class, "respondsToSelector:", new Selector("validateUserInterfaceItem:")).To<bool>())
            {
                enabled = SuperCall(NSWindowController.Class, "validateUserInterfaceItem:", sender).To<bool>();
            }

            return enabled;
        }
开发者ID:andyhebear,项目名称:Continuum,代码行数:32,代码来源:BrowseRecentFilesController.cs

示例2: validateUserInterfaceItem

        public bool validateUserInterfaceItem(NSObject sender)
        {
            bool enabled = false;

            Selector sel = (Selector) sender.Call("action");

            if (sel.Name == "dirHandler:")
            {
                int tag = (int) sender.Call("tag");

                var handler = m_boss.Get<IMenuHandler>();
                MenuState state = handler.GetState(tag);
                enabled = (state & MenuState.Enabled) == MenuState.Enabled;
                if (sender.respondsToSelector("setState:"))
                    sender.Call("setState:", (state & MenuState.Checked) == MenuState.Checked ? 1 : 0);

                if (enabled && tag == 50 && sender.isMemberOfClass(NSMenuItem.Class))
                {
                    Unused.Value = sender.Call("setTitle:", NSString.Create("Build " + m_name));
                }
                else if (enabled && tag == 1000 && sender.isMemberOfClass(NSMenuItem.Class))
                {
                    Unused.Value = sender.Call("setTitle:", NSString.Create(m_name + " Preferences"));
                }
            }
            else if (sel.Name == "targetChanged:")
            {
                enabled = m_builder != null && m_builder.CanBuild;
            }
            else if (sel.Name == "renameItem:")
            {
                NSIndexSet selections = m_table.selectedRowIndexes();
                enabled = selections.count() == 1;
            }
            else if (sel.Name == "duplicate:")
            {
                NSIndexSet selections = m_table.selectedRowIndexes();
                enabled = selections.count() > 0 && m_table.editedRow() < 0;	// cocoa crashes if we do a duplicate while editing...
            }
            else if (respondsToSelector(sel))
            {
                enabled = true;
            }
            else if (SuperCall(NSWindowController.Class, "respondsToSelector:", new Selector("validateUserInterfaceItem:")).To<bool>())
            {
                enabled = SuperCall(NSWindowController.Class, "validateUserInterfaceItem:", sender).To<bool>();
            }

            return enabled;
        }
开发者ID:andyhebear,项目名称:Continuum,代码行数:50,代码来源:DirectoryController.cs


注:本文中的MObjc.NSObject.respondsToSelector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。