diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-15 14:54:21 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-15 14:54:21 +0200 |
| commit | 5fa771023dc8757f0b23861ef4dac2b4dd9efaf8 (patch) | |
| tree | de7d9d85901f62df762ed06f3b0d22d8bd3d3498 /UGnome.pas | |
| parent | b7fd5bef05041b4993070d96dd280e815ade89c3 (diff) | |
| download | tuxcmd-5fa771023dc8757f0b23861ef4dac2b4dd9efaf8.tar.xz | |
Tabbing right-click fixesv0.6.44
Diffstat (limited to 'UGnome.pas')
| -rw-r--r-- | UGnome.pas | 69 |
1 files changed, 37 insertions, 32 deletions
@@ -352,6 +352,7 @@ end; function button_press_cb(notebook: PGtkWidget; event: PGdkEventButton; data: gpointer): gboolean; cdecl; forward; function button_release_cb(notebook: PGtkWidget; event: PGdkEventButton; data: gpointer): gboolean; cdecl; forward; function scroll_event_callback(widget: PGtkWidget; event: PGdkEventScroll; user_data: gpointer): gboolean; cdecl; forward; +function label_ebox_button_pressed(widget: PGtkWidget; event: PGdkEventButton; data: pointer): gboolean; cdecl; forward; constructor TEphyNotebook.Create(AOwner: TComponent); begin @@ -454,29 +455,6 @@ begin if CanClose then gtk_notebook_remove_page(GTK_NOTEBOOK(ntb.FWidget), position); end; -function label_ebox_button_pressed(widget: PGtkWidget; event: PGdkEventButton; data: pointer): gboolean; cdecl; -var tab: PGtkWidget; - ntb: TEphyNotebook; - position: integer; -begin - Result := False; - ntb := TEphyNotebook(data); - tab := g_object_get_data(G_OBJECT(widget), 'child'); - position := gtk_notebook_page_num(GTK_NOTEBOOK(ntb.FWidget), GTK_WIDGET(tab)); -// DebugMsg(['@******* label_ebox_button_pressed, button = ', event^.button, ', Position = ', position, ', data = 0x', IntToHex(Integer(data), 8), ', widget = 0x', IntToHex(Integer(widget), 8)]); - - if (((event^.button = 2) and (event^._type = GDK_BUTTON_PRESS)) or // Middle-click - ((event^.button = 1) and (event^._type = GDK_2BUTTON_PRESS))) and // Double-click - Assigned(ntb.FOnTabDoubleClick) then - begin - ntb.FOnTabDoubleClick(ntb, position); - Result := True; - ntb.x_start := -1; - ntb.y_start := -1; - end; -end; - - function TEphyNotebook.AppendPage(Child: TGTKControl; Caption: string): integer; begin Result := InsertPage(ChildrenCount, Child, Caption); @@ -1061,6 +1039,28 @@ begin Result := False; end; +function label_ebox_button_pressed(widget: PGtkWidget; event: PGdkEventButton; data: pointer): gboolean; cdecl; +var tab: PGtkWidget; + ntb: TEphyNotebook; + position: integer; +begin + Result := False; + ntb := TEphyNotebook(data); + tab := g_object_get_data(G_OBJECT(widget), 'child'); + position := gtk_notebook_page_num(GTK_NOTEBOOK(ntb.FWidget), GTK_WIDGET(tab)); +// DebugMsg(['@******* label_ebox_button_pressed, button = ', event^.button, ', Position = ', position, ', data = 0x', IntToHex(Integer(data), 8), ', widget = 0x', IntToHex(Integer(widget), 8)]); + + if (((event^.button = 2) and (event^._type = GDK_BUTTON_PRESS)) or // Middle-click + ((event^.button = 1) and (event^._type = GDK_2BUTTON_PRESS))) and // Double-click + Assigned(ntb.FOnTabDoubleClick) then + begin + ntb.FOnTabDoubleClick(ntb, position); + Result := True; + ntb.x_start := -1; + ntb.y_start := -1; + end; +end; + function button_press_cb(notebook: PGtkWidget; event: PGdkEventButton; data: gpointer): gboolean; cdecl; var tab_clicked: integer; ntb: TEphyNotebook; @@ -1079,12 +1079,14 @@ begin Exit; end; - if (event^.button = 1) and (event^._type = GDK_BUTTON_PRESS) and (tab_clicked >= 0) then + if ((event^.button = 1) or (event^.button = 3)) and (event^._type = GDK_BUTTON_PRESS) and (tab_clicked >= 0) then begin - ntb.x_start := Trunc(event^.x_root); - ntb.y_start := Trunc(event^.y_root); - DebugMsg(['@################# x_start = ', ntb.x_start, ', y_start = ', ntb.y_start]); - ntb.motion_notify_handler_id := g_signal_connect(G_OBJECT(notebook), 'motion-notify-event', G_CALLBACK(@motion_notify_cb), data); + if event^.button = 1 then begin + ntb.x_start := Trunc(event^.x_root); + ntb.y_start := Trunc(event^.y_root); + DebugMsg(['@################# x_start = ', ntb.x_start, ', y_start = ', ntb.y_start]); + ntb.motion_notify_handler_id := g_signal_connect(G_OBJECT(notebook), 'motion-notify-event', G_CALLBACK(@motion_notify_cb), data); + end; if tab_clicked >= 0 then begin if tab_clicked <> gtk_notebook_get_current_page(PGtkNotebook(ntb.FWidget)) then begin @@ -1097,8 +1099,10 @@ begin if Assigned(ntb.FOnTabFocusOnlyEvent) then ntb.FOnTabFocusOnlyEvent(ntb, tab_clicked); end; end; - Result := True; - end else + // don't consume the event if right mouse button pressed - allow display the popup menu + Result := event^.button <> 3; + end else Result := True; // consume the event if not clicked any tab +{ else if (GDK_BUTTON_PRESS = event^._type) and (event^.button = 3) then begin if tab_clicked = -1 then begin // consume event, so that we don't pop up the context menu when the mouse if not over a screen label @@ -1106,7 +1110,7 @@ begin end else // switch to the page the mouse is over, but don't consume the event if (tab_clicked >= 0) then gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), tab_clicked); - end; + end; } end; function scroll_event_callback(widget: PGtkWidget; event: PGdkEventScroll; user_data: gpointer): gboolean; cdecl; @@ -1135,7 +1139,8 @@ begin ntb.FBusy := True; gtk_notebook_set_current_page(PGtkNotebook(ntb.FWidget), page); - if Assigned(ntb.FOnTabSwitchedEvent) then ntb.FOnTabSwitchedEvent(ntb, page, False); + //* FIXME: should this be ShouldFocus = False? + if Assigned(ntb.FOnTabSwitchedEvent) then ntb.FOnTabSwitchedEvent(ntb, page, True); Application.ProcessMessages; ntb.FBusy := False; end; |
