Page 1 of 1

ChartMouseListener() and mousebutton

Posted: Wed Mar 07, 2012 8:31 am
by 15351658
Hi,
is there a possibility to get the pressed mousebutton in the ChartMouseListener-event? (left- middle, right-button)

thanks
juergen

Re: ChartMouseListener() and mousebutton

Posted: Wed Mar 07, 2012 8:51 am
by 15351658
... and how can i get the mouseposition on screen in the event?

ju

Re: ChartMouseListener() and mousebutton

Posted: Wed Mar 07, 2012 11:09 am
by yeray
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) { }
		});

Re: ChartMouseListener() and mousebutton

Posted: Wed Mar 07, 2012 11:33 am
by 15351658
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

Re: ChartMouseListener() and mousebutton

Posted: Wed Mar 07, 2012 12:50 pm
by yeray
Hi Juergen,

Excuse me, my fault.
You are right, this has been added in TeeChart Java v3.