summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2024-08-19 15:00:03 +0800
committerXusheng <xusheng@vector35.com>2024-09-25 10:30:30 -0400
commitc8f7d51460e5c9c19d40985c764d7dad6ff4ac72 (patch)
tree395cc2067bb920e5b9ee58a342fb7b15dc402fe9
parent1c9ed05fd356a1cc0aafa06963fcd9172a1cc208 (diff)
Add UIContextNotification::OnContextMenuCreated which is called after a context menu is created in linear/graph/hex/types/stack view
-rw-r--r--ui/uicontext.h24
-rw-r--r--ui/viewframe.h2
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();
};
/*!