Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates


Liberty BASIC -- Display Popup Menu

  • Please log in to reply
No replies to this topic

#1 Irfan_A


    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 135 posts

Posted 01 July 2010 - 02:22 AM

Outline : Objective-Requirement-Let's Coding-Mini Quiz

Display popup menu with POPUPMENU command.

Liberty BASIC (i use Liberty BASIC v4.03).

Let's Coding:
To display popup menu in Liberty BASIC, we can use POPUPMENU command. For display it, we must right click. The question is, when the right mouse button has been pressed or released ? For more convenient, we use when the right mouse button has been released. Also the function right click is different with left click that in mostly cases we can single or double click when the left mouse button has been pressed. So, we use when rightButtonUp rather than when rightButtonDown. In the POPUPMENU, we can use ampersand sign (&) and vertical bar sign (|).

  • Ampersand sign (&) is useful to determines the accelerator placement for each menu item and will act as a hotkey (user hold down ALT key and press letter on keyboard). For Windows XP, we can activate hotkey directly via desktop-right click-Properties-Appearance-Effects...-uncheck "Hide underlined letters for keyboard navigation untill I press the ALT key".
  • Vertical bar sign (|) is useful to separate line to be added between the items when the menu is popuped up.
For example, please run this code. This code can change the background color to red or green.
     [COLOR=Blue]open[/COLOR] [COLOR=Green]"Change the Color Background"[/COLOR] [COLOR=Blue]for[/COLOR] graphics[COLOR=Blue] as [/COLOR]#main
     #main [COLOR=Green]"when rightButtonUp [display]"[/COLOR]
     #main [COLOR=Green]"trapclose [quit]"[/COLOR]
     [COLOR=Blue]popupmenu[/COLOR] [COLOR=Green]"&Red"[/COLOR],[red],[COLOR=Green]"&Green"[/COLOR],[green],|,[COLOR=Green]"&Quit"[/COLOR],[quit]
     #main [COLOR=Green]"cls;fill red;flush"[/COLOR]:[COLOR=Blue]wait[/COLOR]
     #main [COLOR=Green]"cls;fill green;flush"[/COLOR]:[COLOR=Blue]wait[/COLOR]
     [COLOR=Blue]close[/COLOR] #main:[COLOR=Blue]end[/COLOR]
Mini Quiz:

  • Why we use when rightButtonUp rather than when rightButtonDown?
  • Please make a program that show us a popup menu that bring us to CodeCall Forum and CodeCall Youtube Channel.
Answer #1. Because for convenient and its function is different from left click.
Answer #2. Example code is given below.
     [COLOR=Blue]open[/COLOR] [COLOR=Green]"CodeCall - #1 Programming Forum"[/COLOR] [COLOR=Blue]for [/COLOR]graphics_nsb [COLOR=Blue]as[/COLOR] #main
     #main [COLOR=Green]"when rightButtonUp [display]"[/COLOR]
     #main [COLOR=Green]"\\ Please, right click to display popup menu."[/COLOR]
     #main [COLOR=Green]"trapclose [quit]"[/COLOR]
     [COLOR=Blue]popupmenu[/COLOR] [COLOR=Green]"&Forum"[/COLOR],[forum],[COLOR=Green]"&Youtube Channel"[/COLOR],[youtube],|,[COLOR=Green]"&Quit"[/COLOR],[quit]
     [COLOR=Blue]run[/COLOR] [COLOR=Green]"explorer http://www.codecall.net"[/COLOR]
     [COLOR=Blue]run[/COLOR] [COLOR=Green]"explorer http://www.youtube.com/codecalltutorials"[/COLOR]
    [COLOR=Blue] close[/COLOR] #main:[COLOR=Blue]end[/COLOR]

Attached Thumbnails

  • Clipboard01..jpg

  • 0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download