Plua 選單

lua-users home
wiki

請注意此頁面僅與 Plua 1.1 相關(PluaPalmVersion)。Plua 2.0 的語法已變更。

-- SD 2006-10-20

Plua 允許您指定會附加至單一動態選單的選單項目。

您無法在上側建立多個選單,這應為 Palm OS 限制,只允許一個動態選單。

以下是我使用資源編輯器來駭入 PluaRuntime 的探索。

它有功能但用途堪慮,因為您必須駭入 Plua 執行時期(除非使用某些打包技巧或變更簽章)。

只要您為選單項目賦予超過 Plua 範圍的數字(例如:1021),就會起作用。

您的 pmenu 項目會附加至新選單的結尾,而非一般位置。

有趣的是,當我附加第二個新選單時,pmenu 項目仍然出現在第一個新選單的結尾。我不確定這是否

完全可重複,因為有一段時間它們仍出現在主選單上。

我駭入的 Plua 副本中有兩個新選單:tst1 包含 t1 和 t2(然後會附加 pmenu 項目),tst2 包含 t1-1 和 t1-2。

執行 menutest.lua,我得到選單 ID 為

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

也就是說,pevent 傳回的選單 ID 僅從 1 起順序編號,從附加 pmenu 項目的選單開始,忽略 MBAR 資源中設定的任何選單 ID。

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

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

local eh = {}

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

eh[penDown] = function(x,y)
pset(x,y)
end

eh[penMove] = function(x,y)
plineto(x,y)
end

-- handle events using table
repeat
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 · 喜好設定
編輯 · 歷程
最近編輯時間為 2006 年 10 月 21 日上午 3:00 GMT (diff)