Skip to content

Commit 1699a20

Browse files
committed
Add UIContextNotification::OnTokenDoubleClicked hook
Add the OnTokenDoubleClicked notification hook to UIContextNotification, update the API docs comment, and add a Python UINotification example.
1 parent 5037372 commit 1699a20

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

python/examples/ui_notifications.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def OnContextMenuCreated(self, context, view, menu):
9898
# This function only works in C++: Name is an out param (cpp: &name), and not modifiable by python.
9999
print(f"py OnContextMenuCreated {context} {view} {menu}")
100100

101+
def OnTokenDoubleClicked(self, context, frame, view, location, token):
102+
print(f"py OnTokenDoubleClicked {token.token.text!r} @ {location.getOffset():#x}")
103+
return False # return False to let the default double-click behavior run
104+
101105
def OnActionExecutedImmutable(self, context, handler, name, ctx):
102106
print(f"py OnActionExecutedImmutable {context} {handler} {name} {ctx}")
103107

ui/uicontext.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,35 @@ class BINARYNINJAUIAPI UIContextNotification
380380
(void)view;
381381
(void)menu;
382382
}
383+
384+
/*!
385+
Callback when a token is double-clicked, invoked before the view's default
386+
double-click behavior (navigation, rename dialog, etc.). Lets a plugin handle the
387+
token itself, e.g. the debugger navigating to a variable's runtime address.
388+
389+
Notifications are invoked in registration order until one returns true, which
390+
consumes the double-click: no further notifications run and the default behavior is
391+
suppressed. Return false to pass the click on to the other notifications and,
392+
ultimately, the default behavior.
393+
394+
\param context Context containing the view
395+
\param frame ViewFrame containing the view
396+
\param view View in which the token was double-clicked
397+
\param location Location at the time of the click
398+
\param token The token that was double-clicked
399+
\return True if handled (suppressing the default behavior), false to pass it on
400+
*/
401+
virtual bool OnTokenDoubleClicked(
402+
UIContext* context, ViewFrame* frame, View* view, const ViewLocation& location,
403+
const HighlightTokenState& token)
404+
{
405+
(void)context;
406+
(void)frame;
407+
(void)view;
408+
(void)location;
409+
(void)token;
410+
return false;
411+
}
383412
};
384413

385414
/*!
@@ -599,6 +628,8 @@ class BINARYNINJAUIAPI UIContext
599628
void NotifyOnActionExecuted(UIActionHandler* handler, const QString& name, const UIActionContext& ctx, std::function<void(const UIActionContext&)>& action);
600629
void NotifyOnActionExecutedImmutable(UIActionHandler* handler, const QString& name, const UIActionContext& ctx);
601630
void NotifyOnContextMenuCreated(View* view, Menu& menu);
631+
bool NotifyOnTokenDoubleClicked(
632+
ViewFrame* frame, View* view, const ViewLocation& location, const HighlightTokenState& token);
602633

603634
virtual void findAll(const BinaryNinja::FindParameters& params);
604635

0 commit comments

Comments
 (0)