[tekui-devel] tekui: List:addEntry() now accepts table and string values; Text...

Timm S. Mueller tmueller at neoscientists.org
Fri Apr 25 00:10:43 CEST 2008


details:   http://hg.teklib.org/tekui/rev/d23685cfa0cd
changeset: 444:d23685cfa0cd
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Wed Apr 23 20:45:37 2008 +0200
description:
List:addEntry() now accepts table and string values; TextInput: fixed setting
the cursor position

diffs (88 lines):

diff -r 75399584084f -r d23685cfa0cd tek/app/ui/list.lua
--- a/tek/app/ui/list.lua	Wed Apr 23 15:20:43 2008 +0200
+++ b/tek/app/ui/list.lua	Wed Apr 23 20:45:37 2008 +0200
@@ -4,12 +4,13 @@ local ui = require "tek.lib.ui"
 local ui = require "tek.lib.ui"
 
 local list = { }
-for i = 1, 12 do
+for i = 1, 20 do
 	list[i] = { "Line " .. i .. ": The quick brown fox jumps over the lazy dog" }
 end
 
 ui.Application:new
 {
+	Title = "List Test",
 	Children =
 	{
 		ui.Window:new
@@ -26,13 +27,15 @@ ui.Application:new
 						{
 							[ui.NOTIFY_ALWAYS] =
 							{
-								{
-									ui.NOTIFY_SELF, function(self, val)
-										self.Application:getElementById("the-list"):addEntry { self.Label }
-										self:setValue("Label", "")
-										self:setValue("Focus", true)
-									end, ui.NOTIFY_VALUE
-								}
+								{ "the-list", "addEntry", ui.NOTIFY_VALUE },
+								{ ui.NOTIFY_SELF, "setValue", "Label", "", false }, -- do not trigger
+								{ ui.NOTIFY_SELF, "setValue", "Focus", true },
+
+-- 									ui.NOTIFY_SELF, function(self, val)
+-- 										self.Application:getElementById("the-list"):addEntry { self.Label }
+-- 										self:setValue("Label", "")
+-- 										self:setValue("Focus", true)
+-- 									end, ui.NOTIFY_VALUE
 							}
 						}
 					}
diff -r 75399584084f -r d23685cfa0cd tek/class/ui/list.lua
--- a/tek/class/ui/list.lua	Wed Apr 23 15:20:43 2008 +0200
+++ b/tek/class/ui/list.lua	Wed Apr 23 20:45:37 2008 +0200
@@ -17,9 +17,10 @@ local min = math.min
 local min = math.min
 local overlap = ui.Region.overlapCoords
 local remove = table.remove
+local type = type
 
 module("tek.class.ui.list", tek.class.ui.scrollgroup)
-_VERSION = "List 0.18"
+_VERSION = "List 0.19"
 local List = _M
 
 -------------------------------------------------------------------------------
@@ -330,6 +331,8 @@ end
 end
 
 function List:addEntry(entry)
+	entry = type(entry) == "table" and entry or type(entry) == "string" and
+		{ entry }
 	self.Object:addLine(entry)
 end
 
diff -r 75399584084f -r d23685cfa0cd tek/class/ui/textinput.lua
--- a/tek/class/ui/textinput.lua	Wed Apr 23 15:20:43 2008 +0200
+++ b/tek/class/ui/textinput.lua	Wed Apr 23 20:45:37 2008 +0200
@@ -16,7 +16,7 @@ local unpack = unpack
 local unpack = unpack
 
 module("tek.class.ui.textinput", tek.class.ui.text)
-_VERSION = "TextInput 1.31"
+_VERSION = "TextInput 1.32"
 
 -------------------------------------------------------------------------------
 --	Constants & Class data:
@@ -201,9 +201,7 @@ function TextInput:onPress(x, y)
 function TextInput:onPress(x, y)
 	local tr = self.TextRecords[1]
 	local fw, fh = ui.Display:textSize(tr[2], " ")
-	if not x or not y then
-		self.tcursor = 0
-	else
+	if x and y then
 		if x >= self.trect[1] and x <= self.trect[3] and y >= self.trect[2]
 			and y <= self.trect[4] then
 			self.tcursor = floor((x - self.trect[1]) / fw)


More information about the tekui-devel mailing list