How to distinguish right from left click

Hello,

I'm using GanttControl and I wold like to know how I can distinguish the right click from a left click on a taks.

Having seen this question (https://www.syncfusion.com/forums/164085/click-event-on-gantt-chart ) , I know when I have clicked on a task. But I don't know how to distinguish what type of click I have made.

Kind regards,

Jon


1 Reply 1 reply marked as answer

ET Eswaran Thirugnanasambandam Syncfusion Team January 21, 2022 05:55 PM UTC

Hi Jon Guerrero, 
 
Your requirement can be achieved by hooking the required Mouse events in the root element of the GanttNode using Behavior in the CustomNodeStyle as shown in the below snippet. 
 
[XAML] 
<Window.Resources> 
        <Style TargetType="chart:GanttNode" 
               x:Key="TaskNode"> 
     <Setter Property="HorizontalAlignment" 
             Value="Left" /> 
     <Setter Property="Template"> 
         <Setter.Value> 
             <ControlTemplate TargetType="chart:GanttNode"> 
                 <Canvas Height="11"> 
                                  …… 
                       <Border Name="PART_Border"> 
                         <i:Interaction.Behaviors> 
                             <local:GanttNodeCustomizationBehavior /> 
                         </i:Interaction.Behaviors> 
                       </Border> 
                                         ……. 
                 </Canvas> 
                       </ControlTemplate> 
          </Setter.Value> 
     </Setter> 
</Window.Resources> 
<Grid> 
     <gantt:GanttControl ItemsSource="{Binding TaskCollection}"> 
         <gantt:GanttControl.Resources> 
             <Style TargetType="chart:GanttNode" 
                    BasedOn="{StaticResource TaskNode}" /> 
         </gantt:GanttControl.Resources> 
     </gantt:GanttControl> 
 </Grid> 
 
C# 
class GanttNodeCustomizationBehavior : Behavior<Border> 
{                                                                                                                        
    protected override void OnAttached() 
    { 
        this.AssociatedObject.Loaded += new RoutedEventHandler(AssociatedObject_Loaded); 
    }  
     
    void AssociatedObject_Loaded(object sender, RoutedEventArgs e) 
    { 
        this.AssociatedObject.PreviewMouseLeftButtonDown += AssociatedObject_PreviewMouseLeftButtonDown; ; 
        this.AssociatedObject.MouseRightButtonDown += AssociatedObject_MouseRightButtonDown; 
    } 
 
    private void AssociatedObject_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 
    { 
        // Add your codes here. 
    } 
 
    private void AssociatedObject_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 
    { 
        // Add your codes here. 
    } 
 
    protected override void OnDetaching() 
    { 
        this.AssociatedObject.Loaded -= new RoutedEventHandler(AssociatedObject_Loaded); 
    } 
} 
 
We have prepared the sample for the same. Please get it from the below link. 
 
Please refer the below user guide links for more information about custom node style support in the GanttControl. 
 
Please let us know if you have any further assistance. 
 
Regards, 
Eswaran 


Marked as answer
Loader.
Up arrow icon