Help with Combolist Object

OK, the object of this exercise is to put a dropdown list on the desktop. When I make a selection, other configured objects can access it (the current value).

Here is my problem:
I create the Combolist box, and there is nothing in it. The list drops down and it is blank. I have a Default.Value set, and other objects can get that default value, but since there is nothing in the list I can't change my selection.


Below is my script. First thing I do is select the DesktopX Combolist control. The I create the following script:

'Called when the script is executed
Sub Object_OnScriptEnter
Widget.AddPreference "DropDown"
Widget.Preference("DropDown").Type = "ComboList"
Widget.Preference("DropDown").Caption = "Caption"
Widget.Preference("DropDown").Description = "Description"
Widget.Preference("DropDown").DefaultValue = "Nothing in here"
Widget.Preference("DropDown").AddValue "Ping"
Widget.Preference("DropDown").AddValue "Netstat"
Widget.Preference("DropDown").AddValue "traceroute"
End Sub

Sub Object_OnScriptExit

End Sub

As I said all I get is an empty drop down box. I have checked the container properties, etc. and made sure that everything is visible, AFAIK. What am I missing here? Also, what is the difference between this and using CreateForm and defining a form the same way?

Thanks!

Brain21

5,977 views 6 replies
Reply #1 Top
Bump. ANyone? Bueller? Bueller?
Reply #2 Top
Aren't the Widget.Preference atributes displayed on the Properties tab when you right click the object?

But again, I have no DX groove and am likely wrong.
Reply #3 Top
As far as I know, the widget preferences are for an object running as a widget, and show up on the properties dialog. Other Widget methods have the same limitation (like Widget.close, which will do nothing if running as an object with the DesktopX runtime. And for another little gotcha, the DesktopX.HostType property doesn't seem to really work as a way to tell which mode is the environment at the moment - not sure why.) I have not used them much, as I prefer the CreateForm method, or an activeX control on an object of my own creation.

Using DesktopX.CreateForm will work for Object and Widget modes, so is more flexible if you are developing and debugging as objects and then you have the choice to export to widget or gadget (if you have Pro).

Hope this helps ...
Reply #4 Top
OK, tried the CreateForm method, and still got the same thing.

I assume that CreateForm also only works for a preferences popup dialog?

I need to basically have a drop down box on my dekstop. Is this at all possible?

Barring that, what method would I use (or can I do it) to select a file.

For example...

- I have a button labeled "Select Script".
- I have another button labled "Show Script name"
- You click on the "Select Script" button and an explorer window opens up.
- In this explorer window I navigate to C:\test\scripts (assuming the object/widget/gadget is installed to C:\test\).
- I then select TestScript.bat or something like that and click "open" or whatever.
- That window dissapears. Now I got back to my app and click on the button labeled "Show Script Name" and I get a MsgBox that either shows me:

"TestScript.bat" (w/o the quotes)
or
"C:\test\scripts\TestScript.bat" (again w/o quotes).

My goal here is to use several apps in a unified tool.

For example I would like to launch the command:

ping 10.0.0.1

or

plink 10.0.0.1 -l admin -pw password echo hello, world

or

plink 10.0.0.1 -l admin -pw password echo goodbye, world

- So the app would have an ipaddr input field. THis is easy.
- Next step... the user will pick the application (from hopefully a drop down box) that would be either "ping" or "plink"
- 3rd step the user would pick a "script" to run. This would be the explorer window that I described above. In the case of "ping" they would select no script. For plink once "script" would simply contain:

echo goodbye, world

The other script would contain

echo hello, world

The username & password will be hardcoded, so simply selecting "plink" it would automatically send to the command line

plink ipaddr -l admin -pw password
where ipaddr is taken from the input box described earlier.

So, to sum up, I would *LIKE* to have the user select an application (hardcoded in a dropdown), and select a script (somewhere on the machine - if the path needs to be hard-coded then that is fine).

If I can do this all from the object/widget/gadget itself with no preferences dialog, cool. If I *must* have a dialog, then fine too (less elegant). How would I launch that via a button? How do I do the whole file selection thing via user interaction?

Whew!

Thanks,

Brain21
Reply #5 Top
I don't know that Widget.Preference is the best way to approach what you want, if I understand correctly.

Here is an easy way to get a ComboBox on the desktop, and access it by a "button".
Create a new object. On the Summary pane, give the object an ObjectID, "MyComboBoxObj" and also give it a Width of 256 and Height of 32. The Height attribute seems to be the way to adjust font size on these.
"These" being ComboBoxes, so go to the General tab and add a script. Choose the Script dropdown menu from the Script Editor window, then ActiveX Control->Select Control. Select DesktopX ComboBox and click OK.

Replace the script with this sample:
'Called when the script is executed
Sub Object_OnScriptEnter
Control.AddItem("Item Zero")
Control.AddItem("Item One")
Control.AddItem("Item Two")
Control.AddItem("Item Three")
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub


Now create another new object, and add this script:
'Called when the script is executed
Sub Object_OnScriptEnter

End Sub


Sub Object_OnLButtonUp(x, y, d)
MsgBox "The Selected Item is:" & vbNewLine & DesktopX.ScriptObject("MyComboBoxObj").Control.Text
End Sub



'Called when the script is terminated
Sub Object_OnScriptExit

End Sub


Hope that helps!
Reply #6 Top
OK, I figured it out and got it working. I did the same thing as RabidRobot suggested (though I found out on my own by reading through the scripts for the local weather & Satellite object on WinCustomize).

Mine is only slightly different from above. Since I declared a global public variable my DesktopX.ScriptObject(....) has .GlobalVariable (where GlobalVariable is the name I dimmed/decalred elsewhere). Same thing though.

Wish I had seen your answer last night! Would have saved me about an hour's worth of work today.


Or better yet, seen it days ago... I also noticed that until you actually enable the script, the combo box is empty. Enable it and then you see your objects. That's a big DUH! on my part


When I finish I'll clean up the code and pack it all up and throw the dxpack up on WinCustomize or something.

Thanks to everyone for the help & input!!!!

Brain21