DX Controller Scripts... Please help!

Thursday, October 6, 2005 by ExodusCrow | Discussion: DesktopX

I'm trying to figure out controller scripts for DX and I'm running in to a problem. I can't get DX to recognize anything but right clicks on my widget. I've tried this code to test it out. It only produces a message box when I right click, not when I left-click or double click on the widget.

Sub Object_OnScriptEnter
desktopx.RegisterController Object.Name
End Sub

Function OnControl(lType, lCode)
msgbox (lType & " " & lCode)
End function


Also, the documentation states that I can create a custon right click menu for my widget.

For instance you can replace the right click or systray widget menu by returning true to 1 / 1 notification and provide your own menu as described in the preceding chapter.


How do I return true? and where would I place the code for the new menu?

Thanks in advance for the help.

Confused,
ExodusCrow
MountainDragon
Reply #1 Friday, October 7, 2005 12:40 AM
Okay, I tried it, and here's how it seemsk to work (you may have already figured it out):

The control messages are only sent for right-clicks on the widget, and for both right and left clicks on the widget's system tray icon. The type and code arguments seem to be as advertised.

As for your question about a custom right-click menu, here's an example:

Note: This one is set up to just handle the right click on the object, but you could use the same contents for the OnControl notification, as long as you made sure it was for the event you wanted.


Function Object_OnRButtonUp(x,y,dragged)
If Not dragged Then
Dim menu
Set menu = DesktopX.CreatePopupMenu
menu.AppendMenu 0, 1, "Options 1"
menu.AppendMenu 0, 2, "Options 2"
menu.AppendMenu 0, 99, "DesktopX"
Dim rtn
rtn = menu.TrackPopupMenu(0, System.CursorX, System.CursorY)
Select Case rtn
Case 1
'Do something
Case 2
'Do something else
End Select
Set menu = nothing
End If
If rtn <> 99 Then
Object_OnRButtonUp=True ' Here's where we return True so DesktopX won't respond further
End If
End Function

This is covered in the documentation under "Scriptable Popup Menus".
MountainDragon
Reply #2 Friday, October 7, 2005 12:41 AM
Btw, sorry about the lack of formatting in the example, but it gets lost in the post.
ExodusCrow
Reply #3 Friday, October 7, 2005 7:35 AM
Now it makes sense. I didn’t realize the control script was working on events from the system tray. I'll give the code you wrote a try when I get home. Thanks for the response.
thomassen
Reply #4 Friday, October 7, 2005 11:32 AM
hm... the controller script isn't just for system tray... https://www.stardock.com/products/desktopx/documentation/scripting/controllers.html
ExodusCrow
Reply #5 Friday, October 7, 2005 1:10 PM
thomassen, how do you get it to recognize the other events?
thomassen
Reply #6 Saturday, October 8, 2005 8:08 AM
you know what.... when I read the post I went on to do a quick test. without much luck really. I couldn't even get it to respond to the tray icon. However, I know I've used this function before. I'll look into it over this weekend.
Skarny
Reply #7 Monday, November 28, 2005 6:24 AM
to dredge up a topic, do controller scripts work only on widgets? im trying to get the right click menu to not appear on objects so i can use the OnRbuttonup commands on objects without the menu appearing.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01