[tekui-devel] tekui: KeyCode is now part of Gadget, not Text; Gadget: added ke...
Timm S. Mueller
tmueller at neoscientists.org
Thu May 15 00:08:32 CEST 2008
details: http://hg.teklib.org/tekui/rev/9a008db0c1e2
changeset: 494:9a008db0c1e2
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Tue May 13 11:24:23 2008 +0200
description:
KeyCode is now part of Gadget, not Text; Gadget: added keyboard shortcuts
diffs (truncated from 120 to 100 lines):
diff -r f45c6d2f3b97 -r 9a008db0c1e2 bin/choices.lua
--- a/bin/choices.lua Tue May 13 10:50:30 2008 +0200
+++ b/bin/choices.lua Tue May 13 11:24:23 2008 +0200
@@ -23,15 +23,15 @@ ui.Application:new
Legend = "Order Beverages",
Children =
{
- ui.CheckMark:new { Label = "Water" },
- ui.CheckMark:new { Label = "Juice", Disabled = true },
- ui.CheckMark:new { Label = "Milk" },
+ ui.CheckMark:new { Label = "W_ater" },
+ ui.CheckMark:new { Label = "_Juice", Disabled = true },
+ ui.CheckMark:new { Label = "Mil_k" },
ui.Spacer:new { },
- ui.CheckMark:new { Label = "Tea" },
- ui.CheckMark:new { Label = "Coffee" },
+ ui.CheckMark:new { Label = "_Tea" },
+ ui.CheckMark:new { Label = "_Coffee" },
ui.Spacer:new { },
- ui.CheckMark:new { Label = "Beer" },
- ui.CheckMark:new { Label = "Wine" },
+ ui.CheckMark:new { Label = "_Beer" },
+ ui.CheckMark:new { Label = "_Wine" },
},
},
ui.Group:new
@@ -40,15 +40,15 @@ ui.Application:new
Legend = "Are you impressed?",
Children =
{
- ui.RadioButton:new { Label = "Yes" },
- ui.RadioButton:new { Label = "No" },
+ ui.RadioButton:new { Label = "_Yes" },
+ ui.RadioButton:new { Label = "_No" },
ui.Spacer:new { },
- ui.RadioButton:new { Label = "Possibly" },
- ui.RadioButton:new { Label = "Maybe" },
- ui.RadioButton:new { Label = "Perhaps", Disabled = true },
+ ui.RadioButton:new { Label = "_Possibly" },
+ ui.RadioButton:new { Label = "_Maybe" },
+ ui.RadioButton:new { Label = "Per_haps", Disabled = true },
ui.Spacer:new { },
- ui.RadioButton:new { Label = "What, me?" },
- ui.RadioButton:new { Label = "Ask again later" },
+ ui.RadioButton:new { Label = "What, me_?" },
+ ui.RadioButton:new { Label = "Ask again _later" },
},
},
},
diff -r f45c6d2f3b97 -r 9a008db0c1e2 bin/tekui.lua
--- a/bin/tekui.lua Tue May 13 10:50:30 2008 +0200
+++ b/bin/tekui.lua Tue May 13 11:24:23 2008 +0200
@@ -329,7 +329,7 @@ ui.Application:new
{
Width = "auto",
Mode = "button",
- Label = "Cancel",
+ Label = "_Cancel",
VAlign = "center",
Notifications =
{
diff -r f45c6d2f3b97 -r 9a008db0c1e2 tek/class/ui/gadget.lua
--- a/tek/class/ui/gadget.lua Tue May 13 10:50:30 2008 +0200
+++ b/tek/class/ui/gadget.lua Tue May 13 11:24:23 2008 +0200
@@ -53,7 +53,7 @@ local Frame = ui.Frame
local Frame = ui.Frame
module("tek.class.ui.gadget", tek.class.ui.frame)
-_VERSION = "Gadget 6.1"
+_VERSION = "Gadget 7.0"
local Gadget = _M
@@ -82,6 +82,8 @@ function Gadget.init(self)
self.Hold = false
-- The pointer is hovering over the element:
self.Hover = false
+ -- keycode shortcut:
+ self.KeyCode = self.KeyCode or false
-- Mode of behavior ("inert", "toggle", "touch", "button"):
self.Mode = self.Mode or "inert"
-- Element is being "pressed":
@@ -268,6 +270,17 @@ function Gadget:passMsg(msg)
win:setHiliteElement(he)
return false
end
+ elseif msg[2] == ui.MSG_KEYDOWN then
+ if msg[7] == self.KeyCode and not self.Disabled then
+ self.Window:setFocusElement(self)
+ self.Window:setHiliteElement(self)
+ self.Window:setActiveElement(self)
+ end
+ elseif msg[2] == ui.MSG_KEYUP then
+ if msg[7] == self.KeyCode and not self.Disabled then
+ self.Window:setActiveElement()
+ self.Window:setHiliteElement(self.Window.HoverElement)
+ end
end
end
return msg
More information about the tekui-devel
mailing list