Jump to content


Photo

nxPageControl doubleclick


  • Please log in to reply
12 replies to this topic

#1 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 14 September 2007 - 10:58 AM

not critical

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 September 2007 - 11:22 AM

Hello Emailaya,

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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 14 September 2007 - 11:30 AM

i think 1 of the 2:

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 14 September 2007 - 11:35 AM

Hello Emailaya,

I think that I know where is a problem and how to solve it. I will go back here today.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 14 September 2007 - 11:43 AM

ok
10x

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 15 September 2007 - 01:24 AM

Hello Emailaya,

Next code work fine:

CODE
procedure TForm1.NxPageControl1DblClick(Sender: TObject);
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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 15 September 2007 - 05:03 PM

the correct tab is assigned
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 15 September 2007 - 05:14 PM

ok here is the conclusion
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 16 September 2007 - 03:49 AM

Hello Emailaya,

I am not sure what you are tying to archive sad.gif

Next code successfully delete correct page:

CODE
procedure TForm1.NxPageControl1DblClick(Sender: TObject);
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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 16 September 2007 - 10:51 AM

i want to do sth really simple

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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 16 September 2007 - 06:14 PM

my explanation above was ok this time?

#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 16 September 2007 - 10:18 PM

Hello Emailaya,

Open NxPageControl.pas file

Find procedure TNxPageControl.MouseDown and change line:

CODE
    if Assigned(APage) then


into

CODE
    if Assigned(APage) and not (ssDouble in Shift) then


Now use next DblClick event:
CODE
procedure TForm1.NxPageControl1DblClick(Sender: TObject);
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
boki@bergsoft.net | LinkedIn Profile
--
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 emailaya

emailaya

    Master Member

  • Members
  • PipPipPipPipPip
  • 984 posts

Posted 16 September 2007 - 10:35 PM

i just needed this addition
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