[tekui-devel] tekui: added Object:toggleValue() and notify option to setValue(...

Timm S. Mueller tmueller at neoscientists.org
Wed Mar 19 18:40:58 CET 2008


details:   http://hg.teklib.org/tekui/rev/3076b44d4a47
changeset: 370:3076b44d4a47
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Tue Mar 18 22:21:41 2008 +0100
description:
added Object:toggleValue() and notify option to setValue(); added Gadget.Mode
"toggle", "button", "touch"; Window: simplified logic, removed
releaseActiveElement() and clickElement() and KeysPressed, setHiliteElement()
renamed to setHoverElement(); CheckMark: now of Mode "toggle"; RadioButton:
now of Mode "touch", setSelected() renamed to switch(); various adaptions in
demos and other classes

diffs (truncated from 887 to 100 lines):

diff -r f9b3fdf104a6 -r 3076b44d4a47 tek/app/ui/pop.lua
--- a/tek/app/ui/pop.lua	Mon Mar 17 01:40:56 2008 +0100
+++ b/tek/app/ui/pop.lua	Tue Mar 18 22:21:41 2008 +0100
@@ -42,7 +42,7 @@ local success, state = ui.application:ne
 						ui.button:new { Label = "Toggle", Mode = "toggle", HMax = false, Id = "togglebutton" },
 						ui.button:new { Label = "Clickme", HMax = false,
 							onRelease = function(self)
-								self.Application:getElementById("togglebutton"):setValue("Pressed", true)
+								self.Application:getElementById("togglebutton"):toggleValue("Selected")
 							end
 						},
 
diff -r f9b3fdf104a6 -r 3076b44d4a47 tek/app/ui/sudoku.lua
--- a/tek/app/ui/sudoku.lua	Mon Mar 17 01:40:56 2008 +0100
+++ b/tek/app/ui/sudoku.lua	Tue Mar 18 22:21:41 2008 +0100
@@ -140,16 +140,9 @@ function sudokubutton:onRelease()
 	end
 end
 
-function sudokubutton:getElementByXY(x, y)
-	if self.changeable then
-		return ui.button.getElementByXY(self, x, y)
-	end
-end
-
-function sudokubutton:getHiliteByXY(x, y)
-	if self.changeable then
-		return ui.button.getHiliteByXY(self, x, y)
-	end
+function sudokubutton:checkFocus()
+	return self.changeable and ui.button.checkFocus(self)
+
 end
 
 function sudokubutton:draw(bgpen)
diff -r f9b3fdf104a6 -r 3076b44d4a47 tek/class/ui/button.lua
--- a/tek/class/ui/button.lua	Mon Mar 17 01:40:56 2008 +0100
+++ b/tek/class/ui/button.lua	Tue Mar 18 22:21:41 2008 +0100
@@ -31,6 +31,8 @@ local Button = _M
 local Button = _M
 
 function Button.new(class, self)
+	self = self or { }
+	self.Mode = self.Mode or "button"
 	self = Gadget.new(class, self)
 	self.TextArea = TextArea:new {
 		Label = self.Label,
diff -r f9b3fdf104a6 -r 3076b44d4a47 tek/class/ui/checkmark.lua
--- a/tek/class/ui/checkmark.lua	Mon Mar 17 01:40:56 2008 +0100
+++ b/tek/class/ui/checkmark.lua	Tue Mar 18 22:21:41 2008 +0100
@@ -81,7 +81,7 @@ function CheckMark.new(class, self)
 	self = self or { }
 	self.Image = self.Image or CheckImage1
 	self.AltImage = self.AltImage or CheckImage2
-	self.Mode = "toggle"
+	self.Mode = self.Mode or "toggle"
 	return Button.new(class, self)
 end
 
diff -r f9b3fdf104a6 -r 3076b44d4a47 tek/class/ui/gadget.lua
--- a/tek/class/ui/gadget.lua	Mon Mar 17 01:40:56 2008 +0100
+++ b/tek/class/ui/gadget.lua	Tue Mar 18 22:21:41 2008 +0100
@@ -18,11 +18,12 @@
 --
 -------------------------------------------------------------------------------
 
+local db = require "tek.lib.debug"
 local ui = require "tek.lib.ui"
 local Frame = ui.Frame
 
 module("tek.class.ui.gadget", tek.class.ui.frame)
-_VERSION = "Gadget 1.8"
+_VERSION = "Gadget 2.0"
 
 local Gadget = _M
 
@@ -37,13 +38,54 @@ local Gadget = _M
 -- local DEF_BORDERSTYLE = nil -- use frame default
 local DEF_IBORDERSTYLE = "button"
 
+-- local NOTIFY_ONHOLD = { ui.NOTIFY_SELF, "onHold" }
+-- local NOTIFY_TOGGLESELECT = { ui.NOTIFY_SELF, "setSelected" }
+-- local NOTIFY_SELECT = { ui.NOTIFY_SELF, "setValue", "Selected",
+-- 	ui.NOTIFY_VALUE }
+
+
 local NOTIFY_REDRAW = { ui.NOTIFY_SELF, "setValue", "Redraw", true }
 local NOTIFY_ONPRESS = { ui.NOTIFY_SELF, "onPress" }
 local NOTIFY_ONRELEASE = { ui.NOTIFY_SELF, "onRelease" }
-local NOTIFY_ONHOLD = { ui.NOTIFY_SELF, "onHold" }
-local NOTIFY_TOGGLESELECT = { ui.NOTIFY_SELF, "setSelected" }
-local NOTIFY_SELECT = { ui.NOTIFY_SELF, "setValue", "Selected",
-	ui.NOTIFY_VALUE }
+
+local NOTIFY_HOVER = { ui.NOTIFY_SELF, function(self)
+	if self.Mode == "button" then
+		self:setValue("Selected", self.Active and self.Hover)
+	end
+	self:setValue("Hilite", self.Hover)
+end }


More information about the tekui-devel mailing list