KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Select treeview node on right-mouse-click

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
rjdegraff
KiXforms Dabbler
KiXforms Dabbler


Joined: 12 Sep 2007
Posts: 8
Location: Winnipeg, Manitoba, Canada

PostPosted: Thu Mar 12, 2009 2:12 pm    Post subject: Select treeview node on right-mouse-click Reply with quote

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
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Fri Mar 13, 2009 8:53 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sat Mar 14, 2009 3:17 pm    Post subject: Reply with quote

Benny, might want to give GetNodeAt a try anyways Wink
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sat Mar 14, 2009 8:29 pm    Post subject: Reply with quote

Ah Benny your right. I thought this was a classic question ... stay tuned.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Mar 16, 2009 12:40 am    Post subject: Reply with quote

k posted kixforms.net 3.2.15 to dev build sticky ... give a test ...
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Tue Mar 17, 2009 1:56 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group