Object help

display folder contents

I was wondering if anyone could help me out with creating an object that can do a couple of things:
1) On mouse hover, a "speech bubble" appears listing the contents of a specified folder without actually giving the user access to that folder
2) On click, open a drop-down menu that will give access to all the files w/in the folder.

I already know how to make it so on clicking, it will open up the dropdown menu for access to the folder (very simple), but I can't for the life of me get a way to make a speech bubble type popup to appear on hover that simply lists the contents of the linked folder... Any help would be appreciated
1,594 views 9 replies
Reply #1 Top
You need to write a script to do that.

Help : WWW Link
Reply #2 Top
You can also do this with in DX it's self.. Go to properties of your button or object that you want the mouse to hover over.. go to the states tab, On mouse away go to messages click on add..In the next window check (object ID) then browse till you find the name of your object that you want to pop up (You did name your objects???).. then in message pick (HIDE ) now go to mouse over and do the same thing only now the message will be (SHOW) Make sure that you have checked "Object ID " and NOT BROADCAST Ok now go to the relations page and set Visible to (NO) click on apply now when you mouse over your object your bubble will appear.. hope this helps    

This will only make your object show or hide you will still have to fill in the information in your bubble and make the shortcuts to the files...
Reply #3 Top
Code to list files :

Sub Object_OnScriptEnter
Object.ToolTipText = ListDir ("C:\")
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

Function ListDir (Path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Folder: Set Folder = fso.GetFolder(Path)
Dim Files: Set Files = Folder.Files
Dim File
For Each File In Files
ListDir = ListDir & File & vbcrlf
Next
End Function

Problem ist, that the DX-Tooltext only holds a certain amount of lines.
Reply #4 Top
Murex, for your solution I would need a second object that pops up when I hover over the original one (the second object being a popup), correct?
Alright, created a second object - the speechbubble, and it appears whenever I hover over the original one...now I just have to make the speechbubble list all the files in the folder by file name, not path...

Carl, when I tried to use your code, it displayed the entire path name of each file - thus limiting how much it could show (in fact, it only showed one full file path, and then the fist few letters of the next file). Is there a way to make it only display the file name w/o the full path?
Reply #5 Top
Chaos, I believe you'll need to parse the list to get each filename.

Nice script Carl[c242]. You could eliminate the OnScriptEnter sub & update the tooltip text using GetFolder("foldername") or GetParent? within the function. I think something like this: Dim fName: Set fName = fso.GetFolder(foldername) DesktopX.Object("myobject").Tooltip Text = "ListDir" & fName
Reply #6 Top
hmmm, been trying out a few things but none are doing quite what I want...Think maybe I'll get one of my friends to give me a hand with the coding... What language does the script use?

Edit: nvm, uses VB or Java
Reply #7 Top
Carl, when I tried to use your code, it displayed the entire path name of each file - thus limiting how much it could show (in fact, it only showed one full file path, and then the fist few letters of the next file). Is there a way to make it only display the file name w/o the full path?


You will have to use some string coding :

Dim PathLenghth
PathLength = Len(Path) + 1 '(+1 because we don't want to see the backslash)
...
ListDir = ListDir & Mid(File, PathLength, 255) & vbcrlf

All VBScript.

Reply #8 Top
Note Also, that it doesn't see Folders.

A better way : Create 2 Objects (here : DirObject1 and DirObject2), DirObject2 as a brief text object and be sure to group them ! Than assign this Script to DirObject1 :

Sub Object_OnScriptEnter

End Sub
Sub Object_OnMouseEnter
DesktopX.Object("DirObject2").Text = ListFolders ("C:\")& vbcrlf & ListDir ("C:\")
End Sub
Sub Object_OnMouseLeave
DesktopX.Object("DirObject2").Text = ""
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

Function ListDir (Path)
Dim fso
Dim PathLenghth
PathLength = Len(Path) + 1
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Folder: Set Folder = fso.GetFolder(Path)
Dim Files: Set Files = Folder.Files
Dim File
For Each File In Files
ListDir = ListDir & Mid(File, PathLength, 255) & vbcrlf
Next
End Function

Function ListFolders (Path)
Dim fso
Dim PathLenghth
PathLength = Len(Path) + 1
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Folder: Set Folder = fso.GetFolder(Path)
Dim Folders: Set Folders = Folder.SubFolders
Dim Folder1
For Each Folder1 In Folders
ListFolders = ListFolders & "[" & Mid(Folder1, PathLength, 255) & "]" & vbcrlf
Next
End Function

That way You don't have to fiddle with show or hide events.

Reply #9 Top
If you want to add a drop file function to this then add the first part below and make the appropriate changes within the OnMouseEnter sub.

Dim myDirectory

Sub Object_OnDropFiles(files)
Set objFSO = CreateObject("Scripting.FileSystemObject")
folderpath = objFSO.GetFolder(files)
myDirectory = folderpath
End Sub

Sub Object_OnMouseEnter
DesktopX.Object("DirObject2").Text = ListFolders (myDirectory & "\")& vbcrlf & ListDir (myDirectory & "\")
End Sub