本文整理汇总了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;
}
示例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;
}