VCLua v0.3.2

Creating VCLua application step by step

Tutorial 2




With VCLua actions you can improve your applications functionality. Actions can be used both by menus and toolbars, and changing an action property immediately effects these objects.

First you should create an ActionList, and load actions from a lua table

mainActions = VCL.ActionList(mainform,"mainActions")
    {name="fileOpenAction", caption="&Open...", shortcut="Ctrl+O", onexecute="onOpenAction", imageindex=0},
    {name="fileExitAction", caption="&Exit", shortcut="Alt+F4", onexecute="onExitAction", imageindex=1},
    {name="helpAboutAction", caption="&About", shortcut="Alt+F1", onexecute="onAboutAction", imageindex=2},

If the OnExecute method not assigned, then the action will be disabled. To enable/disable the action just assign the onexecute method

mainActions:Get("fileOpenAction").onexecute="onOpenAction" -- enabled
mainActions:Get("fileOpenAction").onexecute=nil -- disabled

Of course the action in itself do nothing. You need reference it from menu or from toolbar.

As you see the actions contains refrence to imageindexes. To continue our development we will need add an IimageList to the application.

mainImages = VCL.ImageList(mainForm,"mainImages")
    "images/open.png", "images/exit.png", "images/help.png"

Now you can build the action based menu and toolbar.

mainMenu = VCL.MainMenu(mainForm,"mainMenu")
mainMenu.Images = mainImages
  {name="mmfile", caption="&File",
  {name="mmhelp", caption="&Help", RightJustify=true,
    submenu = {

mainToolbar = VCL.ToolBar(mainForm,"mainToolbar")
mainToolbar._ = { borderwidth =0, edgeborders = "[ebLeft,ebTop,ebRight,ebBottom]", edgeinner = "esRaised", edgeouter=  "esLowered", autosize = true, buttonwidth = 24, buttonheight = 24, align = alTop, flat = true }
mainToolbar.Images = mainImages