Popup Menu

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Sparky
Newbie
Newbie
Posts: 3
Joined: Thu Mar 31, 2005 5:00 am

Popup Menu

Post by Sparky » Mon Feb 19, 2007 6:53 pm

One thing that has been really bugging me about my TeeChart implementation is the use of a popup menu. When using the built-in scrolling with the right mouse button, the popup menu is displayed on the final mouse up event. To me, the popup menu should be fired only when the right button is clicked and the chart didn't get scrolled. I know that I can implement this with a routine for manually supporting the popup menu, but I would like to know if there is an easier route. I would imagine this would be an issue for a lot of people.

Thanks for any insight into a quick fix for this,

James

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 20, 2007 9:25 am

Hi James,

Sorry but I don't understand what do you exactly mean. What do you mean when you speak about the "popup menu"? Which TeeChart version are you using?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sparky
Newbie
Newbie
Posts: 3
Joined: Thu Mar 31, 2005 5:00 am

Post by Sparky » Tue Feb 20, 2007 4:25 pm

I'm using version 7. The PopupMenu property of a TChart component can be set to a TPopupMenu component to add right-click support to a chart object. At runtime, a user right-clicks on the chart and the menu pops up. The default scroll mechanism for a chart object is to use the right mouse button to click and shift a series within the chart (sliding the series back and forth). After you do this, the popup menu appears. To me, the automatic behavior of the Popup Menu mechanism should be altered in those situations.

I guess this isn't as common a problem as I would have thought. I'm really not sure that I can articulate the problem any better than this.
Last edited by Sparky on Tue Feb 20, 2007 5:37 pm, edited 1 time in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Feb 20, 2007 4:44 pm

Hi Sparky,

You have two options here:

1. Change the mouse button for scrolling a chart, eg:

Code: Select all

  Chart1.ScrollMouseButton := mbMiddle;
2. Only display the popup menu when a chart has been clicked with the right-mouse button but not scrolled, eg.:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = Chart1.ScrollMouseButton then
  begin
    X0:=X;
    Y0:=Y;
  end;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if ((Button = Chart1.ScrollMouseButton) and ((X0<>X) or (Y0<>Y))) then
    //Chart has been scrolled, disable PopUp menu
  else
    //Display PopUp menu
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sparky
Newbie
Newbie
Posts: 3
Joined: Thu Mar 31, 2005 5:00 am

Post by Sparky » Tue Feb 20, 2007 5:46 pm

Thanks for the info Narcis! I didn't think about changing the mouse button that was used. I'm not sure if this will be a problem for people with only 2 buttons although that is a rare occurence these days.

I'm currently using a customized version of the chart commander. I've added a couple more buttons and customized the icons. Since I have a lot of locations that the chart (and associated commander component) is used, it would be great to implement the changes in the commander. This is what I was trying to do before, but I knew that I'd need to made a bunch of tweaks to do it. I was trying to find that elusive shortcut :). I'll need to modify the mouse routines to pass along button information.

Just a side note for anyone reading this thread, the AutoPopup needs to be set to false to manually control the behavior.

Again, thanks for the input. I'm going to go back in and make the changes to the chart commander.

Post Reply