RomanDA's DesktopX Tutorials:
My goal is to make a set
of tutorials for DesktopX. If you have ideas on what you would like to
see, please email me at
DXTutorials@RomanDA.org
Lets make a RIGHT-CLICK menu |
|
Would you like to have a right-click menu that isn't the "standard" one
that DX supplies when you export a widget?
Ok, Read on...
The code for this isn't
really all that hard. |
(
danilloOc's
new player) |
|
'--- Function to handle the RIGHT-Click
Function
Object_OnRButtonUpEx(obj,x,y,dragged)
If Not dragged Then
'-- Do not do anything if someone is dragging the
widget
Object_OnRButtonUpEx = True
Call CreateSectionMenu()
'-- Call the Function that Shows the Menu
End If
End Function
'--- Right Click Menu Creation Function -------
Sub CreateSectionMenu()
Set mainmenu = nothing
Set mainmenu = DesktopX.CreatePopupMenu
'-- Create Main Menu
mainmenu.AppendMenu 0, 1, "About Player"
'-- First item in the menu
mainmenu.AppendMenu 0, 2, "Properties"
'-- Second item in the menu
mainmenu.AppendMenu 0, 3, "Exit"
'-- Third item in the menu (this can continue)
result = mainmenu.TrackPopupMenu(0, System.CursorX,
System.CursorY) '-- Save the results of mouse
movements
Call ExecuteSectionMenu(result,snum)
'-- Run the Function that handles the menu function
called
End Sub
'-- Function to handle the results of the right-click menu action
Sub
ExecuteSectionMenu(result,snum)
Select Case result
'-- Look thru the results to see what was selected
Case 1
'-- Look in the function above 0, 1, "About" - this
is the 1
desktopx.Object("About_Window").Visible = True
'--
show your custom ABOUT window
Case 2
'-- Look in the function above 0, 2, "Prop.." - this is the 2
widget.OpenProperties
'-- Open the Properties for the widget
Case 3
'-- Look in the function above 0, 3, "Exit.." - this is the 3
widget.Close
'-- Close the Widget
' Case 4
End Select
Set mainmenu = nothing
'-- clear the menu
End Sub |
There are a lot of things that
can be done with this, things like SUB menus, etc. Maybe I will look into
that at a later date. Its just a simple example
This script needs to be attached
to any object that you want to have the right-menu active.
This code is part mine, mostly
VAD_M's who is
quickly becoming the GOD of DX scripts!