Plua Menus

lua-users home

Note page relates to Plua 1.1 only (PluaPalmVersion). Syntax has changed in Plua 2.0.

-- SD 2006-10-20

Plua allows you to specify menu items which it attaches to a single dynamic menu.

You can't create a number of menus across the top - this is supposedly a limit of the Palm OS which allows only one dynamic menu.

The following was my exploration of using a resource editor to hack the PluaRuntime

It is functional but of arguable use, given that you'd have to hack the Plua runtime (unless some bundling trick was used or a change in signature).

Provided you give the menu items numbers above the Plua range (eg: 1021) then they work.

Your pmenu items are appended to the end of the new menu, NOT normal location.

Interestingly, when I appended a SECOND new menu, the pmenu items still appeared at the end of the first one. I'm not sure this is

wholly repeatable as for a while they were still appearing on the main Menu.

My hacked copy of Plua has two new menus in it: tst1 contains t1 & t2 (and then gets pmenu items appended) tst2 contains t1-1 and t1-2.

Running menutest.lua, I get a menu id of:

1 for the (resource-added) tst1 item t1
3 for the first item added below by pmenu
7 for the (resource-added) test2 item t1-1

ie: the menu ID's returned from pevent are just sequential from 1, starting from the menu at which the pmenu items appended, ignoring any menu ID's set in the MBAR resource.

-- menutest.lua
-- contact dent@o...
-- reports menu ID's and demonstrates tables for event handling

pdestroy() pclear()
mnu01t = {"Quit","-","mnu01:1","mnu01:2","mnu01'3","mnu01:4"}

local eh = {}

eh[menuSelect] = function(mID)
palert("menu id "..mID)

eh[penDown] = function(x,y)

eh[penMove] = function(x,y)

-- handle events using table
e, e1,e2,e3,e4=pevent()
local f=eh[e]
if f then f(e1,e2,e3,e4) end
until e==keyDown

-- AndyDent 2004-04-23

RecentChanges · preferences
edit · history
Last edited October 21, 2006 2:00 am GMT (diff)