Hi,
I have a problem with ultrachart (9.2 hotfix 2042)...
I need to get right click event on item in ultrachart (GanttChart Type) but with ChartDataClicked event I can't understand which mouse button has been clicked.
My workaroud idea was:
- handle MouseClick event
- in the handler save a boolean field rightClick = true
- in the ChartDataClicked handler check rightClick field
but the problem is that MouseClick event is not fired when you click on items, but only when you click in portion of chart with no item...
Any idea to solve that ?
I also say that I handle chartItemOver-out to show my custom tooltip manager... could it be the problem ?
Thx in advance
It was a stupid question after all :)I thought ChartDataClicked event raised on mouse button release, so I didn't check Control.MouseButtons...My fault, thanks a lot for the help.
P.S.
I got a problem posted here --> LINK
but with no response... It's a ribbon-ultrachart issue so I think that concerns also to this forum section, could you give a look at it ?
Thank a lot again Teodor
You can find which mouse button is clicked with Control.MouseButtons. For example:
if (Control.MouseButtons == MouseButtons.Right)
{
}
Ok, I did it through InteractionTool, as shown in the code below.
Do you think is the best way, or is there one better, less stupid, more efficient ... solution ??
Overridden Interaction Tool Class:
public class EventArgs<T> : EventArgs{ public T Value { get; private set; } public EventArgs(T value) { this.Value = value; }}public class ItemClickInteractionTool : InteractionTool{ #region Public Events public event EventHandler<EventArgs<Primitive>> ChartDataPointClicked; #endregion #region Private Fields MouseButtons mouseButtonFilter; #endregion #region CTOR public ItemClickInteractionTool(UltraChart chart, MouseButtons buttonFilter) : base(chart) { mouseButtonFilter = buttonFilter; } #endregion #region Overrides public override bool CanStart() { if (this.LastInput.MouseEventArgs != null && this.LastInput.MouseEventArgs.Button == this.mouseButtonFilter) { var primitive = this.HitTest(this.LastInput.ViewPoint); if (primitive != null && primitive.DataPoint != null) { return true; } } return false; } public override void Start() { var primitive = this.HitTest(this.LastInput.ViewPoint); if (primitive != null && primitive.DataPoint != null) { this.OnChartDataPointClicked(primitive); } } #endregion #region Private Methods private void OnChartDataPointClicked(Primitive dataPoint) { if (this.ChartDataPointClicked != null) { this.ChartDataPointClicked(this, new EventArgs<Primitive>(dataPoint)); } } #endregion}
Interaction Tool Initialization:
itemRightClickInteractionTool =new ItemClickInteractionTool(this.ultraChart, MouseButtons.Right);itemRightClickInteractionTool.ChartDataPointClicked +=new EventHandler<EventArgs<Primitive>>(itemRightClickInteractionTool_ChartDataPointClicked);ultraChart.AddMouseDownTool(itemRightClickInteractionTool);
Any suggestion ?