@@ -132,7 +132,7 @@ public void Load(IEnumerable<ITreeData> data, string title)
132
132
foldersKeys = Folders . Keys . Cast < string > ( ) . ToList ( ) ;
133
133
}
134
134
135
- public Rect Render ( Rect rect , Vector2 scroll , Action < TreeNode > singleClick = null , Action < TreeNode > doubleClick = null )
135
+ public Rect Render ( Rect rect , Vector2 scroll , Action < TreeNode > singleClick = null , Action < TreeNode > doubleClick = null , Action < TreeNode > rightClick = null )
136
136
{
137
137
Profiler . BeginSample ( "TreeControl" ) ;
138
138
bool visible = true ;
@@ -191,7 +191,7 @@ public Rect Render(Rect rect, Vector2 scroll, Action<TreeNode> singleClick = nul
191
191
{
192
192
if ( visible )
193
193
{
194
- RequiresRepaint = HandleInput ( rect , node , i , singleClick , doubleClick ) ;
194
+ RequiresRepaint = HandleInput ( rect , node , i , singleClick , doubleClick , rightClick ) ;
195
195
}
196
196
rect . y += ItemHeight + ItemSpacing ;
197
197
}
@@ -257,7 +257,7 @@ private int ToggleNodeVisibility(int idx, TreeNode rootNode)
257
257
return idx ;
258
258
}
259
259
260
- private bool HandleInput ( Rect rect , TreeNode currentNode , int index , Action < TreeNode > singleClick = null , Action < TreeNode > doubleClick = null )
260
+ private bool HandleInput ( Rect rect , TreeNode currentNode , int index , Action < TreeNode > singleClick = null , Action < TreeNode > doubleClick = null , Action < TreeNode > rightClick = null )
261
261
{
262
262
bool selectionChanged = false ;
263
263
var clickRect = new Rect ( 0f , rect . y , rect . width , rect . height ) ;
@@ -267,14 +267,20 @@ private bool HandleInput(Rect rect, TreeNode currentNode, int index, Action<Tree
267
267
SelectedNode = currentNode ;
268
268
selectionChanged = true ;
269
269
var clickCount = Event . current . clickCount ;
270
- if ( clickCount == 1 && singleClick != null )
270
+ var mouseButton = Event . current . button ;
271
+
272
+ if ( mouseButton == 0 && clickCount == 1 && singleClick != null )
271
273
{
272
274
singleClick ( currentNode ) ;
273
275
}
274
- if ( clickCount > 1 && doubleClick != null )
276
+ if ( mouseButton == 0 && clickCount > 1 && doubleClick != null )
275
277
{
276
278
doubleClick ( currentNode ) ;
277
279
}
280
+ if ( mouseButton == 1 && clickCount == 1 && rightClick != null )
281
+ {
282
+ rightClick ( currentNode ) ;
283
+ }
278
284
}
279
285
280
286
// Keyboard navigation if this child is the current selection
0 commit comments