OnMouseEvent Method  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
zysmn
Posts: 68
Joined: 27 Feb 2014
Has thanked: 7 times
Been thanked: 4 times

OnMouseEvent Method

Postby zysmn » 24 Jun 2014

Hi.

I am trying to use next code for testing OnMouseEvent Method

Code: Select all

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator{
public class _test_onMouseEvent : IndicatorObject {
public _test_onMouseEvent(object _ctx):base(_ctx){}
private IPlotObject plot1;
protected override void Create() {
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar(){
// indicator logic
plot1.Set(Bars.Close[0]);
}
protected override void OnMouseEvent(MouseClickArgs args)
{
if (Keys.ShiftKey == args.keys && MouseButtons.Left == args.buttons)
{
MessageBox.Show("Triggered !!! "+args.bar_number.ToString());
}
}
}
}
but when I press leftClick+shift, nothing is happening, OnMouseEvent does not work, and MessageBox never appears.
Whats wrong?

Fabrice
Posts: 182
Joined: 14 Jun 2011
Has thanked: 44 times
Been thanked: 30 times

Re: OnMouseEvent Method  [SOLVED]

Postby Fabrice » 24 Jun 2014

Add the attribute

Code: Select all

[MouseEvents]
F.

PS: see http://www.tradingcode.net/multicharts- ... ck-events/
Last edited by Fabrice on 24 Jun 2014, edited 1 time in total.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: OnMouseEvent Method

Postby Henry MultiСharts » 24 Jun 2014

Hello zysmn,

There are some errors in the code. Please refer to the prebuilt "MouseEventsExample" indicator to learn how to implement the logic properly.

zysmn
Posts: 68
Joined: 27 Feb 2014
Has thanked: 7 times
Been thanked: 4 times

Re: OnMouseEvent Method

Postby zysmn » 24 Jun 2014

Fabrice, grateful for your help and for the link.
Henry MultiСharts, thanks for the tip, i'll check it.


Return to “MultiCharts .NET”