Forum > LCL

[Solved] TPageControl right click pop-up menu

<< < (2/2)

GetMem:

--- Quote from: petevick on January 27, 2023, 11:17:32 am ---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  :-\

--- End quote ---
I'm not following you. Can you make a screenshot?

PS: Did you clear PageControl1.PopupMenu?

petevick:

--- Quote from: GetMem on January 27, 2023, 11:34:05 am ---I'm not following you. Can you make a screenshot?

PS: Did you clear PageControl1.PopupMenu?

--- End quote ---
Yes I cleared that. The code wasn't testing for the right mouse button being pressed, so with a slight tweek, it now does.....


--- 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);     if Button = mbRight then TabNames.PopUp(P.X, P.Y);   end;end;

GetMem:
@petevick

--- Quote --- Yes I cleared that. The code wasn't testing for the right mouse button being pressed, so with a slight tweek, it now does.....

--- End quote ---

Ok. Now I see what you meant. You can move Button = mbRight to the first line, so if the condition is not met the code will exit immediately.

--- 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 (Button = mbRight) and (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, 11:44:44 am ---Ok. Now I see what you meant. You can move Button = mbRight to the first line, so if the condition is not met the code will exit immediately.

--- 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 (Button = mbRight) and (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 ---

That's even better, thanks again for your help GetMem  ;)

GetMem:
@petevick

--- Quote ---That's even better, thanks again for your help GetMem  ;)

--- End quote ---
You're more then welcome!

Navigation

[0] Message Index

[*] Previous page

Go to full version