diff options
| -rw-r--r-- | ui/uicontext.h | 24 | ||||
| -rw-r--r-- | ui/viewframe.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/ui/uicontext.h b/ui/uicontext.h index f8bfbcd3..0a4b54ea 100644 --- a/ui/uicontext.h +++ b/ui/uicontext.h @@ -323,6 +323,29 @@ class BINARYNINJAUIAPI UIContextNotification (void)ctx; (void)action; } + + /*! + Callback when a context menu is created, allowing plugins to modify the menu, + e.g., registering and adding new actions into it. This allow plugins to add + new entries into the top-level context menu in a non-hacky way. However, it + is advised that the plugin should only use this instead of PluginCommand::Register + or similar APIs when it is necessary. Besides, if a plugins wishes to add multiple + actions, it is better to put them as sub-menus under a single top-level entry, + avoiding making the context menu crowded. + + This only works for linear/graph/hex/types/stack view due to the way other views + create the context menus. + + \param context + \param view + \param menu + */ + virtual void OnContextMenuCreated(UIContext* context, View* view, Menu& menu) + { + (void)context; + (void)view; + (void)menu; + } }; /*! @@ -528,6 +551,7 @@ public: void NotifyOnAddressChange(ViewFrame* frame, View* view, const ViewLocation& location); void updateCrossReferences(ViewFrame* frame, View* view, const SelectionInfoForXref& selection); void NotifyOnActionExecuted(UIActionHandler* handler, const QString& name, const UIActionContext& ctx, std::function<void(const UIActionContext&)>& action); + void NotifyOnContextMenuCreated(View* view, Menu& menu); virtual void findAll(const BinaryNinja::FindParameters& params); diff --git a/ui/viewframe.h b/ui/viewframe.h index fab2314c..260939f0 100644 --- a/ui/viewframe.h +++ b/ui/viewframe.h @@ -256,6 +256,8 @@ class BINARYNINJAUIAPI View static void registerActions(); static void registerLateActions(); + + void notifyContextMenuCreated(); }; /*! |
