Forum > LCL

[Solved] TPageControl right click pop-up menu

(1/2) > >>

petevick:
In Linux the TPageControl has a pop-up menu when you right click on the tab bar, this is not the PopupMenu property. In Windows this does not work. So initially I created a TPopupMenu for the PopupMenu property, this works fine in both Linux and Windows, BUT, the pop-up menu will pop-up anywhere on the TPageControl, which kinda makes sense, but I would really like it just to pop-up when the tab bar is right clicked.
I Could overlay a TTabControl, but that seems overkill for just a pop-up menu, and more coding.
Any other suggestions would be welcome

GetMem:

--- Quote from: petevick on January 27, 2023, 10:24:33 am ---In Linux the TPageControl has a pop-up menu when you right click on the tab bar, this is not the PopupMenu property. In Windows this does not work. So initially I created a TPopupMenu for the PopupMenu property, this works fine in both Linux and Windows, BUT, the pop-up menu will pop-up anywhere on the TPageControl, which kinda makes sense, but I would really like it just to pop-up when the tab bar is right clicked.
I Could overlay a TTabControl, but that seems overkill for just a pop-up menu, and more coding.
Any other suggestions would be welcome

--- End quote ---
Clear PageControl PopupMenu property, then:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);var  P: TPoint;begin   if Y < PageControl1.Height - TabSheet1.Height - Tabsheet1.BorderWidth then   begin     P.X := X;     P.Y := Y;     P := PageControl1.ClientToScreen(P);     PopupMenu1.PopUp(P.X, P.Y);   end;end;  

petevick:

--- Quote from: GetMem on January 27, 2023, 10:51:19 am ---Clear PageControl PopupMenu property, then:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);var  P: TPoint;begin   if Y < PageControl1.Height - TabSheet1.Height - Tabsheet1.BorderWidth then   begin     P.X := X;     P.Y := Y;     P := PageControl1.ClientToScreen(P);     PopupMenu1.PopUp(P.X, P.Y);   end;end;  
--- End quote ---
Good grief GetMem, what a brilliantly simple solution.  8-) 8-) 8-) Thank you very much indeed  ;) ;)

petevick:
Actually, the pop-up menu displays when you click on the tabs as well as right click this also fires the mouseup event, and unfortunatly there is no right mouse click event  :(

....so I use the Shift to check for right click  :-\

petevick:
....or even Button  %)

Navigation

[0] Message Index

[#] Next page

Go to full version