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

Treeview and FocusedNode

 
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting
View previous topic :: View next topic  
Author Message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Oct 06, 2006 12:58 pm    Post subject: Treeview and FocusedNode Reply with quote

Is there a way to return the focused node versus the selected node. I have a treeview that I need to be able to right-click an item and choose from various options without specifically selecting it (left-clicking) first. I am only able to return the selected node which more than likely is not the focused one.

Thanks!

_________________
-Ben
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 Oct 06, 2006 1:18 pm    Post subject: Reply with quote

Are you talking about wanting to use a contextmenu on a 'treeview'?
_________________
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
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Oct 06, 2006 1:42 pm    Post subject: Reply with quote

Affirmative.
_________________
-Ben
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 Oct 06, 2006 1:54 pm    Post subject: Reply with quote

here is an example of a 'treeview' and 'contextmenu':
Code:

Break On

$System = CreateObject("Kixtart.System")
If Not $System
   $nul= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

$Form = $System.Form()
$Form.Size = 200,300
$Form.Text = "Blank Form"
$Form.Font = $System.Font("Verdana",10)

$StatusBar = $Form.StatusBar()
$StatusBar.Dock = "Bottom"

$Treeview = $Form.Controls.TreeView()
$Treeview.Dock = "Fill"
$Treeview.ImageList = $System.BuiltinImageList()
$Treeview.ImageIndex = 45
$TreeView.LabelEdit = false
$Treeview.SelectedImageIndex = 46
$Treeview.OnMouseDown = "TreeViewMouseDown()"

$Treeview.ContextMenu = $System.ContextMenu()

$Treeview.ContextMenu.ExpandMenu = $Treeview.ContextMenu.MenuItems.Add("Expand")
$Treeview.ContextMenu.ExpandMenu.Visible = 1
$Treeview.ContextMenu.ExpandMenu.Enabled = true
$Treeview.ContextMenu.ExpandMenu.Onclick = "OnExpandClick()"

$Treeview.ContextMenu.CollapseMenu = $Treeview.ContextMenu.MenuItems.Add("Collapse")
$Treeview.ContextMenu.CollapseMenu.Visible = 1
$Treeview.ContextMenu.CollapseMenu.Enabled = false
$Treeview.ContextMenu.CollapseMenu.OnClick = "OnCollapseClick()"

$RootCount = 3
$ChildCount = 3
$GrandChildCount = 3
For $i = 1 to $RootCount
   $RootNode = $TreeView.Nodes.Add("Node$i")
   For $j = 1 to $ChildCount
      $ChildNode = $RootNode.Nodes.Add("Child$j")
      For $k = 1 to $GrandChildCount
         $GrandChildNode = $ChildNode.Nodes.Add("GrandChild$k")
      Next
   Next
Next

$Form.Center
$Form.Show

While $Form.Visible
   $= Execute($Form.DoEvents())
Loop

Exit 0

Function TreeViewMouseDown()
   
   Dim $Node
   
   $Node = $TreeView.GetNodeAt($TreeView.MouseX,$TreeView.MouseY)
   
   If Not $Node
      Return
   EndIf
   
   If Not ($TreeView.MouseButton & 2) ;; Not right-click ?
      Return
   EndIf
   
   $TreeView.SelectedNode = $Node
   
   If $Node.Nodes.Count > 0
      If $Node.Expanded = 0
         $Treeview.ContextMenu.ExpandMenu.Enabled = true
         $Treeview.ContextMenu.CollapseMenu.Enabled = false
      Else
         $Treeview.ContextMenu.ExpandMenu.Enabled = false
         $Treeview.ContextMenu.CollapseMenu.Enabled = true
      EndIf
   Else
      $Treeview.ContextMenu.ExpandMenu.Enabled = false
      $Treeview.ContextMenu.CollapseMenu.Enabled = false
   EndIf
   
   $= $Treeview.ContextMenu.Show($TreeView,$TreeView.MouseX,$TreeView.MouseY)
   
EndFunction

Function OnExpandClick()
   
   If $TreeView.SelectedNode
      $TreeView.SelectedNode.Expand()
   EndIf
   
EndFunction

Function OnCollapseClick()
   
   If $TreeView.SelectedNode
      $TreeView.SelectedNode.Collapse()
   EndIf
   
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
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Oct 06, 2006 2:02 pm    Post subject: Reply with quote

That looks good. Thanks
_________________
-Ben
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 Oct 06, 2006 2:05 pm    Post subject: Reply with quote

glad i could help
_________________
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 -> Advanced Scripting 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