Page 1 of 1

Popup Menu

Posted: Mon Feb 19, 2007 6:53 pm
by 9341469
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

Posted: Tue Feb 20, 2007 9:25 am
by narcis
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.

Posted: Tue Feb 20, 2007 4:25 pm
by 9341469
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.

Posted: Tue Feb 20, 2007 4:44 pm
by narcis
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;

Posted: Tue Feb 20, 2007 5:46 pm
by 9341469
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.