View previous topic :: View next topic |
Author |
Message |
rjdegraff KiXforms Dabbler

Joined: 12 Sep 2007 Posts: 8 Location: Winnipeg, Manitoba, Canada
|
Posted: Thu Mar 12, 2009 2:12 pm Post subject: Select treeview node on right-mouse-click |
|
|
When I click the right mouse button (but do not release it) on a non-selected tree node, the treenode highlights (as if it was now selected). When I release the mouse button, the highlighting goes back to the previously selected node. This makes it confusing for a user. If, for example, the pop-up menu function is "Delete Node", the user might get the impression that the (temporarily) highlighted node is the one that will be deleted. In fact, the node that would be deleted is TreeViewControl.SelectedNode. Is there any way to make the temporarily selected node the ACTUAL selected node? _________________ Sacred cows make the tastiest burgers. |
|
Back to top |
|
 |
benny69 KiXforms Advocate


Joined: 30 Oct 2003 Posts: 567 Location: Lincoln, Ne
|
Posted: Fri Mar 13, 2009 8:53 am Post subject: |
|
|
Hi rjdegraff,
What you are seeing is an action of the internal design of the TreeView, the SelectNode Event is built into the TreeView, by design looks at the left click to select a Node. This is not something that Shawn would or probably even be able to change.
There is a possible work around but you will need to convince Shawn to add a Method called GetNodeAt, this Method would allow one to catch a specific Node at a particular MousePosition.
If you can convince him to do so, I have an Example worked up to show you how to do it. _________________ Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta) |
|
Back to top |
|
 |
Shawn KiXforms Developer


Joined: 22 Feb 2003 Posts: 1983 Location: Canada
|
Posted: Sat Mar 14, 2009 3:17 pm Post subject: |
|
|
Benny, might want to give GetNodeAt a try anyways  |
|
Back to top |
|
 |
Shawn KiXforms Developer


Joined: 22 Feb 2003 Posts: 1983 Location: Canada
|
Posted: Sat Mar 14, 2009 8:29 pm Post subject: |
|
|
Ah Benny your right. I thought this was a classic question ... stay tuned. |
|
Back to top |
|
 |
Shawn KiXforms Developer


Joined: 22 Feb 2003 Posts: 1983 Location: Canada
|
Posted: Mon Mar 16, 2009 12:40 am Post subject: |
|
|
k posted kixforms.net 3.2.15 to dev build sticky ... give a test ... |
|
Back to top |
|
 |
benny69 KiXforms Advocate


Joined: 30 Oct 2003 Posts: 567 Location: Lincoln, Ne
|
Posted: Tue Mar 17, 2009 1:56 am Post subject: |
|
|
ok, with alot of blood, sweat and tears from Shawn (Thanks Shawn, Yo Da Man!), here is the code.
you will need to go get your self the latest build of KiXforms.Net 3.2.16
give it a spin and let me know if its what your looking for:
Code: |
Break On
$System = CreateObject("Kixforms.System")
If Not $System
$nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
$Form = $System.Form()
$Form.StartPosition = 1 ;FormStartPosition_CenterScreen
$Form.Size = $System.Size(400,300) ;(Width,Height)
$Form.Text = "Form TreeView Node Example"
$ContextMenu = $System.ContextMenu()
$DeleteNode = $ContextMenu.MenuItems.Add($System.MenuItem("Delete Node"))
$DeleteNode.Click = "DeleteTreeViewNode()"
$TreeView = $System.TreeView()
$TreeView.ContextMenu = $ContextMenu
$TreeView.Dock = 3 ;Left
$TreeView.LabelEdit = -1 ;True
$TreeView.MouseDown = "CheckForRightMouseClick($$System.Sender)"
$nul = $Form.Controls.Add($TreeView)
$TreeViewNode0 = $TreeView.Nodes.Add($System.TreeNode("Node0"))
$TreeViewNode1 = $TreeViewNode0.Nodes.Add($System.TreeNode("Node1"))
$TreeViewNode2 = $TreeViewNode0.Nodes.Add($System.TreeNode("Node2"))
$TreeViewNode3 = $TreeViewNode0.Nodes.Add($System.TreeNode("Node3"))
$Form.Show ;Displays the Form
While $Form.Visible
$Nul = Execute($Form.DoEvents())
Loop
Exit 0
Function CheckForRightMouseClick($Control)
$Button = $Control.MouseDownEventArgs.Button
If $Button = $System.MouseButtons_Right
$Point = $Control.PointToClient($Control.MousePosition)
$Top = $Point.y
$Left = $Point.x
$Node = $Control.GetNodeAt($Left,$Top)
$TreeView.SelectedNode = $Node
EndIf
EndFunction
Function DeleteTreeViewNode()
$TreeView.SelectedNode.Remove
EndFunction
|
_________________ Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta) |
|
Back to top |
|
 |
|