nxPageControl doubleclick
#1
Posted 14 September 2007 - 10:58 AM
http://www.bergsoft....?showtopic=1341
read AIM second post above
click works perfect
the problem is with doubleclick, here is the code i have:
GetCursorPos(CursorPoint);
CursorPoint := PageControl1.ScreenToClient(CursorPoint);
with PageControl1 do R := Rect(0, TopIndent, ClientWidth, TabHeight + TopIndent);
if PtInRect(R, CursorPoint) then
begin
Tab := PageControl1.GetTabAtPos(CursorPoint.X, CursorPoint.Y);
if (Tab = nil) or (Tab.PageIndex < 2) then
begin
if (Tab = nil) and (PageControl1.GetButtonAtPos(CursorPoint) = pbNone) then
btn.Click;
exit;
end;
PageControl1PageClose(nil,Tab.PageIndex,Accept);
if not Accept then exit;
PageControl1.RemovePage(Tab);
PageControl1.ActivePageIndex := 0;
end;
if i doubleclick on the tab itself it works ok, the first tab becomes active
if i doubleclick inside the red part (see above link), the tab on the left becomes active, and not the first one
#2
Posted 14 September 2007 - 11:22 AM
I will test your code today and try to find a solution. I think that one part of additional code need to be added here for detecting when user click on previous tab.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 14 September 2007 - 11:30 AM
1) doubleclick consists of 2 clicks, so mayb the 2nd click "thinks" it was on the left tab
2) the fix u made for 1 click which is working now, should be done for the doubleclick event as well
#4
Posted 14 September 2007 - 11:35 AM
I think that I know where is a problem and how to solve it. I will go back here today.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#5
Posted 14 September 2007 - 11:43 AM
10x
#6
Posted 15 September 2007 - 01:24 AM
Next code work fine:
var
R: TRect;
CursorPoint: TPoint;
APage: TNxTabSheet;
begin
GetCursorPos(CursorPoint);
CursorPoint := NxPageControl1.ScreenToClient(CursorPoint);
with NxPageControl1 do R := Rect(0, TopIndent, ClientWidth, TabHeight + TopIndent);
if PtInRect(R, CursorPoint) then
begin
APage := NxPageControl1.GetTabAtPos(CursorPoint.X, CursorPoint.Y);
if APage <> nil then
begin
ShowMessage(APage.Caption);
end;
end;
end;
Tab edges are well checked and correct tab is shown in ShowMessage. You need also to note that DblClick first call 1 click and this change tab first.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#7
Posted 15 September 2007 - 05:03 PM
in my code, the double clicked tab is removed as it should
PageControl1PageClose(nil,Tab.PageIndex,Accept);
if not Accept then exit;
PageControl1.RemovePage(Tab); <----
PageControl1.ActivePageIndex := 0;
but instead of making pageindex 0 the default
the left tab is being default
if i double click, not in the red marked (see my fist post here)
then everything is ok
#8
Posted 15 September 2007 - 05:14 PM
it seems that
procedure TNxPageControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
is executed AFTER OnDblClick event is triggered
and since the click was over the left tab (that would be the case when i remove the doubleclicked tab)
that tab becomes active
#9
Posted 16 September 2007 - 03:49 AM
I am not sure what you are tying to archive
Next code successfully delete correct page:
var
R: TRect;
CursorPoint: TPoint;
APage: TNxTabSheet;
begin
GetCursorPos(CursorPoint);
CursorPoint := NxPageControl1.ScreenToClient(CursorPoint);
with NxPageControl1 do R := Rect(0, TopIndent, ClientWidth, TabHeight + TopIndent);
if PtInRect(R, CursorPoint) then
begin
APage := NxPageControl1.GetTabAtPos(CursorPoint.X, CursorPoint.Y);
if APage <> nil then
begin
NxPageControl1.RemovePage(APage);
end;
end;
end;
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#10
Posted 16 September 2007 - 10:51 AM
double click on a tab will close it
and it does close
but then i want the first tab to be active (pagecontrol1.activepageindex := 0) (look in the code in my first post here)
that works ok, if i doubleclick NOT on the red marked
if i doubleclick ON the red marked the tab on the left becomes active
and that is bcoz OnMouseDown event is triggered when DblClick event finishes to execute
#11
Posted 16 September 2007 - 06:14 PM
#12
Posted 16 September 2007 - 10:18 PM
Open NxPageControl.pas file
Find procedure TNxPageControl.MouseDown and change line:
into
Now use next DblClick event:
var
R: TRect;
CursorPoint: TPoint;
APage: TNxTabSheet;
begin
GetCursorPos(CursorPoint);
CursorPoint := NxPageControl1.ScreenToClient(CursorPoint);
with NxPageControl1 do R := Rect(0, TopIndent, ClientWidth, TabHeight + TopIndent);
if PtInRect(R, CursorPoint) then
begin
APage := NxPageControl1.GetTabAtPos(CursorPoint.X, CursorPoint.Y);
if APage <> nil then
begin
NxPageControl1.RemovePage(APage);
NxPageControl1.ActivePageIndex := 0; // <----- new line
end;
end;
end;
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#13
Posted 16 September 2007 - 10:35 PM
if Assigned(APage) and not (ssDouble in Shift) then
the code that i posted in my original post here worked gr8
except for when i doubleclicked on the red part
now the addition: if Assigned(APage) and not (ssDouble in Shift) then
did the trick and its working
10x!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











