Your DesktopX Documentation Resource Guide

Documentation Home

Quick Start

User's Guide

Developer's Guide

Resources

Tutorials


Let's 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.

 
'--- 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!


7/29 

SkinStudio 6.2 Released

7/25 

A God Has Fallen - New Demigod Trailer Released

7/24 

Sins of a Solar Empire v1.1 Beta has Arrived

7/23 

Stardock Releases New WindowBlinds 6.2 Update

7/22 

Stardock Releases The Political Machine v1.04 with New Characters

7/22 

Stardock Releases MyColors 2.5

7/17 

DesktopX 3.5 Officially Released

7/11 

Corel WinDVD 9 and Painter X Now Available on Impulse!