[tekui-devel] tekui: Reverted some changes in PopRadioItem; the popup no longe...

Timm S. Mueller tmueller at neoscientists.org
Mon Apr 28 21:33:56 CEST 2008


details:   http://hg.teklib.org/tekui/rev/e0f390b358dc
changeset: 452:e0f390b358dc
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Fri Apr 25 21:36:55 2008 +0200
description:
Reverted some changes in PopRadioItem; the popup no longer collapsed when
entries were selected

diffs (75 lines):

diff -r 5d01f2b7fae2 -r e0f390b358dc tek/class/ui/popradioitem.lua
--- a/tek/class/ui/popradioitem.lua	Fri Apr 25 18:41:14 2008 +0200
+++ b/tek/class/ui/popradioitem.lua	Fri Apr 25 21:36:55 2008 +0200
@@ -63,6 +63,8 @@ local DEF_IBORDERSTYLE = "" -- none
 local DEF_IBORDERSTYLE = "" -- none
 local DEF_IMAGEMINHEIGHT = 18
 
+local NOTIFY_ONRELEASE = { ui.NOTIFY_SELF, "onPressed", true }
+
 -------------------------------------------------------------------------------
 --	PopRadioItem class:
 -------------------------------------------------------------------------------
@@ -87,15 +89,59 @@ function PopRadioItem.init(self)
 	return PopItem.init(self)
 end
 
+function PopRadioItem:setupDisplay(display, drawable)
+	local theme = display.Theme
+	if not self.Children then
+		-- outer spacing:
+		self.Margin = self.Margin or theme.CheckMarkMargin or DEF_MARGIN
+		-- outer border:
+		self.Border = self.Border or theme.CheckMarkBorder or false
+		-- inner border:
+		self.IBorder = self.IBorder or theme.CheckMarkIBorder or false
+		-- inner spacing:
+		self.Padding = self.Padding or theme.CheckMarkPadding or false
+		-- outer borderstyle:
+		self.BorderStyle = self.BorderStyle or theme.CheckMarkBorderStyle or
+			DEF_BORDERSTYLE
+		-- inner borderstyle:
+		self.IBorderStyle = self.IBorderStyle or theme.CheckMarkIBorderStyle or
+			DEF_IBORDERSTYLE
+	end
+	return PopItem.setupDisplay(self, display, drawable)
+end
+
+-------------------------------------------------------------------------------
+--	connectGlobal:
+-------------------------------------------------------------------------------
+
+function PopRadioItem:connectGlobal(app, window)
+	if not self.Children then
+		-- NOTIFY_ONRELEASE must be connected prior to adding the notifications
+		-- in the baseclass, as those cause the popup tree to collapse:
+		self:addNotify("Pressed", false, NOTIFY_ONRELEASE)
+	end
+	PopItem.connectGlobal(self, app, window)
+end
+
+-------------------------------------------------------------------------------
+--	disconnectGlobal:
+-------------------------------------------------------------------------------
+
+function PopRadioItem:disconnectGlobal()
+	PopItem.disconnectGlobal(self)
+	if not self.Children then
+		self:remNotify("Pressed", false, NOTIFY_ONRELEASE)
+	end
+end
+
 -------------------------------------------------------------------------------
 --	setSelected:
 -------------------------------------------------------------------------------
 
-function PopRadioItem:onSelect(selected)
-	if selected then
+function PopRadioItem:onPressed(pressed)
+	if pressed == true then
 		if self.PopupBase and self.PopupBase:getClass() == PopRadioItem then
 			self.PopupBase:setValue("Label", self.Label)
 		end
 	end
-	PopItem.onSelect(self, selected)
 end


More information about the tekui-devel mailing list