Context Menu
Previous topic  First topic  Next topic


Context Menu is a SUB control that user can create it into another control or window

E.g.:

CREATE BUTTON myButton
   ...
   ...
   ...
   CREATE CONTEXT MENU
      ...
      ...
   END MENU
   ...
END BUTTON






Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE CONTEXT MENU [ cName ] 
      [ FONTNAME "cFontName" ]
Parent.Fontname
  Font family for control text
      [ FONTSIZE nPoints ]
Parent.FontSize
  Font size for control text
      [ FONTBOLD .T. | .F. ]
.F.
  
Set Bold attribute to control text
      [ FONTITALIC .T. | .F. ]
.F.
  
Set Italic attribute to control text
      [ FONTUNDERLINE .T. | .F. ]
.F.
  
Set Underline attribute to control text
      [ FONTSTRIKEOUT .T. | .F. ]
.F.
  
Set Strikeout attribute to control text
      [ FONTCOLOR {aFontColor} | aVarFontColor ]
OS.FontColor
  
Set foreground color (text color)
      [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  
Set background color
      [ PARENT cControlParent ]   
Get or Set the control name of parent widget
      [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
      [ TOOLTIP cToolTip ]
NIL
  Text for display into tooltip
      [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the control. Go to to learn more about it.
       CREATE ITEM cName    
You can see description for this menu in MAIN MENU control.
            [ ......... ]   
 
            [ ......... ]   
 
       END ITEM    
 
      [ CREATE ITEM ]   
 
            [ ......... ]   
 
            [ ......... ]   
 
      [ END ITEM ]   
 
      [ CREATE POPUP ]   
 
            [ ......... ]   
 
            [ ......... ]   
 
            [ CREATE ITEM ]   
 
                  [ ......... ]   
 
                  [ ......... ]   
 
            [ END ITEM ]   
 
            [ CREATE ITEM ]   
 
                  [ ......... ]   
 
                  [ ......... ]   
 
            [ END ITEM ]   
 
      [ END POPUP ]   
 
END MENU    
 

Jump to Main Menu Topic



Example:

Yo can see examples in each first control of each page of maindemo tab.

STYLE page of maindemo has a lot of controls with context menu properties:


File: d_style_def.prg

#include "marinas-gui.ch"

Function d_style_def()

     CREATE CONTEXT MENU

        CREATE ITEM "Item 1 from Context Menu from main Container"
           ONCLICK { || mg_MsgInfo( "Item 1 from Context Menu from main Container" ) }
           PICTURE "../resource/d_test.png"
        END ITEM

        CREATE ITEM "Item 2 from Context Menu from main Container"
           ONCLICK { || mg_MsgInfo( "Item 2 from Context Menu from main Container" ) }
           PICTURE "../resource/d_test.png"
        END ITEM

        CREATE ITEM "Item 3 from Context Menu from main Container"
           ONCLICK { || mg_MsgInfo( "Item 3 from Context Menu from main Container" ) }
        END ITEM

        CREATE POPUP "More items Popup A"

           CREATE ITEM "Popup A Item 1 from Context Menu from main Container"
              ONCLICK { || mg_MsgInfo( "Popup A Item 1 from Context Menu from main Container" ) }
              PICTURE "../resource/d_test.png"
           END ITEM

           CREATE ITEM "Popup A Item 2 from Context Menu from main Container"
              ONCLICK { || mg_MsgInfo( "Popup A Item 2 from Context Menu from main Container" ) }
              PICTURE "../resource/d_test.png"
           END ITEM

           SEPARATOR

           CREATE ITEM "Popup A Item 3 from Context Menu from main Container"
              ONCLICK { || mg_MsgInfo( "Popup A Item 3 from Context Menu from main Container" ) }
           END ITEM

        END POPUP

        CREATE ITEM "Item 4 from Context Menu from main Container"
           ONCLICK { || mg_MsgInfo( "Item 4 from Context Menu from main Container" ) }
           PICTURE "../resource/d_test.png"
        END ITEM

        SEPARATOR

        CREATE ITEM "Item 5 from Context Menu from main Container"
           ONCLICK { || mg_MsgInfo( "Item 5 from Context Menu from main Container" ) }
           PICTURE "../resource/d_test.png"
        END ITEM

     END MENU

     CREATE FRAMEBOX Style_FrameBox_1
            ROW    20
            COL    10
            WIDTH  792
            HEIGHT 401
            FONTCOLOR {232,13,35}
            CAPTION "Use the right mouse button to display the CONTEXT menu controls"

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from FrameBox"
                  ONCLICK { || mg_MsgInfo( "Item 1 from FrameBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from FrameBox"
                  ONCLICK { || mg_MsgInfo( "Item 2 from FrameBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END FRAMEBOX

     CREATE LABEL Style_Label_1
            ROW    50
            COL    130
            AUTOSIZE .T.
            VALUE "Select new Style from RadioGroup:"
            FONTSIZE 12
            FONTBOLD .T.
            BACKCOLOR {0,128,128}
            FONTCOLOR {255,255,255}

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Label"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Label" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Label"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Label" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END LABEL

     CREATE RADIOGROUP Style_RadioGroup
            COL    440
            ROW    50
            WIDTH  300
            HEIGHT 160
            FONTBOLD .T.
            FONTITALIC .T.
            ITEMS {'MarinasLooks','Fusion','Plastique (Discontinued from Qt 5.x)','CDE (Discontinued from Qt 5.x)','Motif (Discontinued from Qt 5.x)','Windows','WindowsXP (Only for Windows XP)','WindowsVista (Only for Windows Vista)','Macintosh (Only Mac OS X)'}
            VALUE 1
            FONTCOLOR {0,0,255}
            ONCHANGE {|| ChangeStyle() }
            TOOLTIP "Select new Style from RadioGroup"

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from RadioGroup"
                  ONCLICK { || mg_MsgInfo( "Item 1 from RadioGroup" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from RadioGroup"
                  ONCLICK { || mg_MsgInfo( "Item 2 from RadioGroup" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END RADIOGROUP

     CREATE FRAMEBOX Style_FrameBox_2
            ROW    90
            COL    20
            WIDTH  400
            HEIGHT 313
            CAPTION "Examples"
     END FRAMEBOX

     CREATE FRAMEBOX Style_FrameBox_3
            ROW    230
            COL    440
            WIDTH  353
            HEIGHT 173
            CAPTION "More Examples"
     END FRAMEBOX

    CREATE BUTTON Style_Button_1
           ROW    260
           COL    450
           WIDTH  50
           HEIGHT 28
           CAPTION "Button"
           ONCLICK mg_Log( "Button from Style" )

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Button"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Button" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Button"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Button" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END BUTTON

    CREATE CHECKBOX Style_Check_1
           ROW    310
           COL    460
           WIDTH  50
           HEIGHT 28
           CAPTION "Ok"
           TOOLTIP "CheckBox ToolTip"
           VALUE .T.

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from CheckBox"
                  ONCLICK { || mg_MsgInfo( "Item 1 from CheckBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from CheckBox"
                  ONCLICK { || mg_MsgInfo( "Item 2 from CheckBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END CHECKBOX

     CREATE SLIDER Style_Slider_1
            ROW    350
            COL    450
            WIDTH  50
            HEIGHT 35
            RANGEMIN 1
            RANGEMAX 10
            VALUE 3
            TOOLTIP "Slider ToolTip"
            ONCHANGE mg_set( "d_window" , "Style_ProgressBar_1" , "value" , mg_get( "d_window" , "Style_Slider_1" , "value" ) )

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Slider"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Slider" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Slider"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Slider" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END SLIDER

     CREATE SPINNER Style_Spinner_1
            ROW    260
            COL    510
            WIDTH  50
            HEIGHT 28
            RANGEMIN 1
            RANGEMAX 10
            VALUE    6
            TOOLTIP "Spinner ToolTip"

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Spinner"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Spinner" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Spinner"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Spinner" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END SPINNER

     CREATE TEXTBOX Style_Text_1
            ROW    310
            COL    510
            WIDTH  50
            HEIGHT 23
            VALUE  "TextBox"
            FONTCOLOR {255,255,255}
            BACKCOLOR {20,100,222}
            TOOLTIP "TextBox ToolTip"

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from TextBox"
                  ONCLICK { || mg_MsgInfo( "Item 1 from TextBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from TextBox"
                  ONCLICK { || mg_MsgInfo( "Item 2 from TextBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END TEXTBOX

     CREATE PROGRESSBAR Style_ProgressBar_1
            ROW    350
            COL    510
            WIDTH  50
            HEIGHT 34
            RANGEMIN 1
            RANGEMAX 10
            VALUE 4
            TOOLTIP "ProgressBar ToolTip"

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from ProgressBar"
                  ONCLICK { || mg_MsgInfo( "Item 1 from ProgressBar" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from ProgressBar"
                  ONCLICK { || mg_MsgInfo( "Item 2 from ProgressBar" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END PROGRESSBAR

     CREATE CALENDAR Style_Calendar_1
            ROW    260
            COL    570
            WIDTH  210
            HEIGHT 124
            FONTSIZE 8
            TOOLTIP "Calendar Default"
            ONDBLCLICK mg_msginfo( DtoC( mg_Get( "d_window" , "Style_Calendar_1" , "value" ) ) )

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Calendar"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Calendar" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Calendar"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Calendar" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END CALENDAR

     CREATE TREEVIEW Style_TreeView_1
            ROW    120
            COL    35
            WIDTH  95
            HEIGHT 268
            VALUE 16
            FONTSIZE 10
            TOOLTIP "TreeView Tooltip"
            ONDBLCLICK mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "Style_TreeView_1" , "value" ) ) + " (" + mg_Get( "d_window" , "Style_TreeView_1" , "item" , mg_Get( "d_window" , "Style_TreeView_1" , "value" ) ) + ")" )
            ONENTER    mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "Style_TreeView_1" , "value" ) ) + " (" + mg_Get( "d_window" , "Style_TreeView_1" , "item" , mg_Get( "d_window" , "Style_TreeView_1" , "value" ) ) + ")" )

            CREATE TREEITEM "Argentina"
               PICTURE   "../resource/d_banner_argentina.png"

               CREATE TREEITEM "Buenos Aires"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Ramallo"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Quilmes"
                  PICTURE   "../resource/d_test.png"

                  CREATE TREEITEM "Quilmes Centro"
                  END TREEITEM

                  CREATE TREEITEM "Quilmes Oeste"
                  END TREEITEM

                  CREATE TREEITEM "Bernal"
                  END TREEITEM

                  CREATE TREEITEM "Don Bosco"
                     PICTURE   "../resource/d_test.png"
                  END TREEITEM

                  CREATE TREEITEM "Ezpeleta"
                     PICTURE   "../resource/d_test.png"
                  END TREEITEM

               END TREEITEM

               CREATE TREEITEM "El Calafate"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Sáenz Peña"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

            END TREEITEM

            CREATE TREEITEM "Bulgary"
               PICTURE   "../resource/d_banner_bulgary.png"

               CREATE TREEITEM "Sofia"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Burgas"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Dobrich"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM
            END TREEITEM

            CREATE TREEITEM "Hungary"
               PICTURE   "../resource/d_banner_hungary.png"

               CREATE TREEITEM "Budapest"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Pécs"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Debrecen"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

            END TREEITEM

            CREATE TREEITEM "Poland"
               PICTURE   "../resource/d_banner_poland.png"

               CREATE TREEITEM "Varsovia"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Radom"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Kielce"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

            END TREEITEM

            CREATE TREEITEM "India"
               PICTURE   "../resource/d_banner_india.png"

               CREATE TREEITEM "Nueva Delhi"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Pune"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Jaipur"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

            END TREEITEM

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from TreeView"
                  ONCLICK { || mg_MsgInfo( "Item 1 from TreeView" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from TreeView"
                  ONCLICK { || mg_MsgInfo( "Item 2 from TreeView" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END TREEVIEW

     CREATE LISTBOX Style_List_1
            ROW    120
            COL    150
            WIDTH  138
            HEIGHT 102
            ITEMS  {'List_1','List_2','List_3','List_4','List_5'}
            ITEMSICONS  {"../resource/d_banner_poland.png","../resource/d_banner_india.png","../resource/d_banner_argentina.png","../resource/d_banner_bulgary.png","../resource/d_banner_hungary.png"}
            VALUE  2

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from ListBox"
                  ONCLICK { || mg_MsgInfo( "Item 1 from ListBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from ListBox"
                  ONCLICK { || mg_MsgInfo( "Item 2 from ListBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END LISTBOX

     CREATE COMBOBOX Style_Combo_1
            ROW    120
            COL    300
            WIDTH  100
            HEIGHT 30
            ITEMS  {'Combo_1','Combo_2','Combo_3'}

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from ComboBox"
                  ONCLICK { || mg_MsgInfo( "Item 1 from ComboBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from ComboBox"
                  ONCLICK { || mg_MsgInfo( "Item 2 from ComboBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END COMBOBOX

     CREATE GRID Style_Grid_1
            ROW    240
            COL    150
            WIDTH  251
            HEIGHT 74
            COLUMNHEADERALL {'Column1','Column2'}
            ITEMS {{"Alpha","Beta"},;
                   {"Gamma","Pi"},;
                   {"Epsilon","Pi"},;
                   {"Gamma","Pi"} }
     //     WIDTHS {60,60,120}
            BACKCOLOR {255,223,255}
            VALUE  1

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Grid"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Grid" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Grid"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Grid" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END GRID

     CREATE IMAGE Style_Image_1
            ROW    160
            COL    300
            WIDTH  102
            HEIGHT 62
            PICTURE "../resource/argentina_in_motorcycle.png"
            SCALED .T.
            ALIGN Qt_AlignCenter
            BACKCOLOR {0,0,255}

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from Image"
                  ONCLICK { || mg_MsgInfo( "Item 1 from Image" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from Image"
                  ONCLICK { || mg_MsgInfo( "Item 2 from Image" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

    END IMAGE

     CREATE EDITBOX Style_Edit_1
            ROW    330
            COL    150
            WIDTH  252
            HEIGHT 58
            VALUEHTML 'Editbox with HTML text sample' + ;
                      '' + ;
                      'Editbox with HTML text sample

' + ;
                      'This is a red line


' + ;
                      'This is a default color line

'

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from EditBox"
                  ONCLICK { || mg_MsgInfo( "Item 1 from EditBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from EditBox"
                  ONCLICK { || mg_MsgInfo( "Item 2 from EditBox" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END EDITBOX

Return .T.

Function ChangeStyle()
   Local aStyle := {'MarinasLooks','Fusion','Plastique','CDE','Motif','Windows','WindowsXP (Only in Windows XP)','WindowsVista (Only in Windows Vista)','Macintosh (Only Mac OS X)'}
   Local nStyle := mg_Get( "d_window" , "Style_RadioGroup" , "value" )
   if nStyle > 0
      SET APPLSTYLE TO ( mg_Word( aStyle[ nStyle ] , 1 ) )
      RefreshTitle()
   endif
Return .T.



Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: March 09
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Jump to Donation Topic


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic