ChartMouseListener() and mousebutton

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Juergen
Newbie
Newbie
Posts: 6
Joined: Fri Feb 06, 2009 12:00 am

ChartMouseListener() and mousebutton

Post by Juergen » Wed Mar 07, 2012 8:31 am

Hi,
is there a possibility to get the pressed mousebutton in the ChartMouseListener-event? (left- middle, right-button)

thanks
juergen

Juergen
Newbie
Newbie
Posts: 6
Joined: Fri Feb 06, 2009 12:00 am

Re: ChartMouseListener() and mousebutton

Post by Juergen » Wed Mar 07, 2012 8:51 am

... and how can i get the mouseposition on screen in the event?

ju

Yeray
Site Admin
Site Admin
Posts: 8746
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ChartMouseListener() and mousebutton

Post by Yeray » Wed Mar 07, 2012 11:09 am

Hi Juergen,

The following code seems to work fine for me here:

Code: Select all

		tChart1.addChartMouseListener(new ChartMouseListener() {
			
			@Override
			public void titleClicked(ChartMouseEvent e) { }
			
			@Override
			public void legendClicked(ChartMouseEvent e) { }
			
			@Override
			public void backgroundClicked(ChartMouseEvent e) {
				String s;
				switch (e.getButton()) {
					case FrameworkMouseEvent.BUTTON1: s = "Left Button";
					break;
					case FrameworkMouseEvent.BUTTON2: s = "Middle Button";
					break;
					case FrameworkMouseEvent.BUTTON3: s = "Right Button";
					break;
					default: s = "No Button";
					break;
				}
				tChart1.getHeader().setText(s);
			}
			
			@Override
			public void axesClicked(ChartMouseEvent e) { }
		});
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Juergen
Newbie
Newbie
Posts: 6
Joined: Fri Feb 06, 2009 12:00 am

Re: ChartMouseListener() and mousebutton

Post by Juergen » Wed Mar 07, 2012 11:33 am

I'm sorry, it does not work. The "getButton()"-function from the ChartMouseEvent is not accepted. May be my TeeChart version (2008) ist to old?

juergen

Yeray
Site Admin
Site Admin
Posts: 8746
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ChartMouseListener() and mousebutton

Post by Yeray » Wed Mar 07, 2012 12:50 pm

Hi Juergen,

Excuse me, my fault.
You are right, this has been added in TeeChart Java v3.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply