diff options
author | 2009-02-14 15:14:37 -0500 | |
---|---|---|
committer | 2009-02-14 15:14:37 -0500 | |
commit | 8ea898e863c8c62fc0230d1c76d58bc477a16d14 (patch) | |
tree | 3ef140fd116b037041a77ad69b1da45dde38d4d3 /src/lua_interface.c | |
parent | 95aca18efb8ace6d241070f52e3b092396d90aad (diff) | |
download | textadept-8ea898e863c8c62fc0230d1c76d58bc477a16d14.tar.gz textadept-8ea898e863c8c62fc0230d1c76d58bc477a16d14.zip |
Added textadept.context_menu field for a custom popup context menu.
Diffstat (limited to 'src/lua_interface.c')
-rw-r--r-- | src/lua_interface.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lua_interface.c b/src/lua_interface.c index b6739c15..369fd90d 100644 --- a/src/lua_interface.c +++ b/src/lua_interface.c @@ -748,6 +748,26 @@ void l_handle_scnnotification(SCNotification *n) { } /** + * Requests and pops up a context menu for the Scintilla view. + * @param event The mouse button event. + */ +void l_ta_popup_context_menu(GdkEventButton *event) { + lua_getglobal(lua, "textadept"); + if (lua_istable(lua, -1)) { + lua_getfield(lua, -1, "context_menu"); + if (lua_isuserdata(lua, -1)) { + GtkWidget *menu = l_togtkwidget(lua, -1); + gtk_widget_show_all(menu); + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, + event ? event->button : 0, + gdk_event_get_time(reinterpret_cast<GdkEvent*>(event))); + } else if (!lua_isnil(lua, -1)) + warn("textadept.context_menu is not a gtkmenu."); + lua_pop(lua, 1); // textadept.context_menu + } else lua_pop(lua, 1); +} + +/** * Executes a given command string as Lua code. * @param command Lua code to execute. */ |