Hi!
For those who might be interested since this is the scripting blog, below
is the 3 hotkeys for adding, deleting, and checking a checkbox in my Breaking
News program. My next posting will be the creation of the tree view.
Bruce
Hotkeys set when the dialog is first created:
Set myAlertSpace = Keyboard.RegisterHotkey("Space", "Click_Button",
dObj.Window, "Click")
Set myAlertReturn = Keyboard.RegisterHotkey("Enter", "Click_Button",
dObj.Window, AddBtnLabel)
Set myAlertDelete = Keyboard.RegisterHotkey("Delete", "Click_Button",
dObj.Window, DeleteBtnLabel)
'Note the above hotkeys are destroyed when entering the editbox but inserted
after exiting the edit box.
Sub Click_Button( dId)
'Add, Delete, Or Check and Uncheck A Checkbox
Dim dObj: Set dObj = myAlertDialog 'Global Alert - Tree View Dialog.
' Check Box item:
If dId = "Click" Then
If TV_Data Mod 10 <> 5 Then Exit Sub 'Tree SubItem 5 is checkbox.
If TV_Obj.Checked = TvcChecked Then
TV_Obj.Checked = TvcUnChecked
TV_Obj.Text = "False"
Else
TV_Obj.Checked = TvcChecked
TV_Obj.Text = "True"
End If
Sleep 250
Exit Sub
End If
'Add A Tree Item Name:
'Note: it works only at top level, when data value is 0, max subitems is 9.
'Once last item is created, it takes you to it and focus is given to it.
If TV_Data Mod 10 = 0 And dId = AddBtnLabel Then
If myEditboxChanged Then
GetSubNode myTreeName, MyTreeRoot, MyLastTreeChild, dObj, Split(
dObj.Control( AlertEditboxName).Text & "|||10|False", "|"), TreeCount
myEditboxChanged = False
Else
GetSubNode myTreeName, MyTreeRoot, MyLastTreeChild, dObj, Split(
"|||10|False", "|"), TreeCount
End If
Sleep 200
MyLastTreeChild.Selected = True
MyLastTreeChild.Text = "New Item"
MyLastTreeChild.ScrollTo
Set TV_Obj = MyLastTreeChild
If Not TV_Obj.Expanded Then TV_Obj.Expanded = True
Sleep 250
Exit Sub
End If
'Now if delete key is pressed, delete tree item:
'Note: Once again must be at top level item to work, max of 9 subitems.
'Once deleted you must know if you are deleting last item in order to focus to
previous.
If TV_Data Mod 10 = 0 And dId = DeleteBtnLabel Then
Dim previousChild, count
count = MyTreeRoot.Children.Count
Set previousChild = Nothing
If count > 1 And TV_Obj.Data = MyTreeRoot.Children( count).Data Then Set
previousChild = MyTreeRoot.Children.Item( count-1)
TV_Obj.Delete()
If Not previousChild Is Nothing Then
previousChild.Selected = True
previousChild.ScrollTo
Sleep 250
Speak previousChild.Text & count-1 & " Of " & count-1 & " Selected "
Sleep 1000
End If
Exit Sub
End If
'Below is reassignment of hotkeys while in edit box:
'Enter key hit when editbox had changed:
If dId = SaveBtnLabel Then Queue "SaveEditboxText", dObj
'Alt-End key hit:
If dId = ReadBtnLabel Then Queue "AlertWebPage", "rp"
'When Alt-Page Down key hit:
If dId = LoadBtnLabel Then Queue "AlertWebPage", "pd"
End Sub
Comment:
All the above hotkey functions are used for the tree view items and edit
box. the label at the bottom of the screen are changed depending on the event
of the tree view and edit box, such as TreeViewSelectionChange, and
EditboxChanged
Bruce
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com