aboutsummaryrefslogtreecommitdiff
path: root/src/textadept.c
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-02-14 15:14:37 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-02-14 15:14:37 -0500
commit8ea898e863c8c62fc0230d1c76d58bc477a16d14 (patch)
tree3ef140fd116b037041a77ad69b1da45dde38d4d3 /src/textadept.c
parent95aca18efb8ace6d241070f52e3b092396d90aad (diff)
downloadtextadept-8ea898e863c8c62fc0230d1c76d58bc477a16d14.tar.gz
textadept-8ea898e863c8c62fc0230d1c76d58bc477a16d14.zip
Added textadept.context_menu field for a custom popup context menu.
Diffstat (limited to 'src/textadept.c')
-rw-r--r--src/textadept.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/textadept.c b/src/textadept.c
index ee2f4da6..2b0a17d0 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -20,6 +20,7 @@ GtkWidget *window, *focused_editor, *menubar, *statusbar, *docstatusbar;
static void t_notification(GtkWidget*, gint, gpointer lParam, gpointer);
static void t_command(GtkWidget *editor, gint wParam, gpointer, gpointer);
static gbool t_keypress(GtkWidget*, GdkEventKey *event, gpointer);
+static gbool t_buttonpress(GtkWidget*, GdkEventButton *event, gpointer);
static gbool w_focus(GtkWidget*, GdkEventFocus *, gpointer);
static gbool w_keypress(GtkWidget*, GdkEventKey *event, gpointer);
static gbool w_exit(GtkWidget*, GdkEventAny*, gpointer);
@@ -243,7 +244,9 @@ void create_ui() {
GtkWidget *new_scintilla_window(sptr_t buffer_id) {
GtkWidget *editor = scintilla_new();
gtk_widget_set_size_request(editor, 1, 1); // minimum size
+ SS(SCINTILLA(editor), SCI_USEPOPUP, 0, 0);
signal(editor, "key_press_event", t_keypress);
+ signal(editor, "button_press_event", t_buttonpress);
signal(editor, "command", t_command);
signal(editor, SCINTILLA_NOTIFY, t_notification);
l_add_scintilla_window(editor);
@@ -491,6 +494,17 @@ static gbool t_keypress(GtkWidget*, GdkEventKey *event, gpointer) {
}
/**
+ * Signal for a Scintilla mouse click.
+ * If it is a right-click, popup a context menu.
+ * @see l_ta_popup_context_menu
+ */
+static gbool t_buttonpress(GtkWidget*, GdkEventButton *event, gpointer) {
+ if (event->type != GDK_BUTTON_PRESS || event->button != 3) return FALSE;
+ l_ta_popup_context_menu(event);
+ return TRUE;
+}
+
+/**
* Signal for a Textadept window focus change.
*/
static gbool w_focus(GtkWidget*, GdkEventFocus*, gpointer) {