[tekui-devel] tekui: Element now loses focus if it is being disabled

Timm S. Mueller tmueller at neoscientists.org
Wed Apr 9 22:00:20 CEST 2008


details:   http://hg.teklib.org/tekui/rev/66913c7a8005
changeset: 414:66913c7a8005
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Wed Apr 09 19:00:07 2008 +0200
description:
Element now loses focus if it is being disabled

diffs (56 lines):

diff -r ee9d6b08d933 -r 66913c7a8005 tek/class/ui/gadget.lua
--- a/tek/class/ui/gadget.lua	Wed Apr 09 18:13:29 2008 +0200
+++ b/tek/class/ui/gadget.lua	Wed Apr 09 19:00:07 2008 +0200
@@ -20,7 +20,7 @@ local Frame = ui.Frame
 local Frame = ui.Frame
 
 module("tek.class.ui.gadget", tek.class.ui.frame)
-_VERSION = "Gadget 3.7"
+_VERSION = "Gadget 3.8"
 
 local Gadget = _M
 
@@ -32,6 +32,7 @@ local NOTIFY_HOVER = { ui.NOTIFY_SELF, "
 local NOTIFY_HOVER = { ui.NOTIFY_SELF, "setHover" }
 local NOTIFY_ACTIVE = { ui.NOTIFY_SELF, "setActive" }
 local NOTIFY_STATE = { ui.NOTIFY_SELF, "setState" }
+local NOTIFY_DISABLED = { ui.NOTIFY_SELF, "setDisabled", ui.NOTIFY_VALUE }
 
 -------------------------------------------------------------------------------
 --	Class implementation:
@@ -57,7 +58,7 @@ end
 
 function Gadget:connectGlobal(app, window)
 	Frame.connectGlobal(self, app, window)
-	self:addNotify("Disabled", ui.NOTIFY_ALWAYS, NOTIFY_STATE)
+	self:addNotify("Disabled", ui.NOTIFY_ALWAYS, NOTIFY_DISABLED)
 	self:addNotify("Hilite", ui.NOTIFY_ALWAYS, NOTIFY_STATE)
 	self:addNotify("Selected", ui.NOTIFY_ALWAYS, NOTIFY_STATE)
 	self:addNotify("Hover", ui.NOTIFY_ALWAYS, NOTIFY_HOVER)
@@ -73,7 +74,7 @@ function Gadget:disconnectGlobal()
 	self:remNotify("Hover", ui.NOTIFY_ALWAYS, NOTIFY_HOVER)
 	self:remNotify("Selected", ui.NOTIFY_ALWAYS, NOTIFY_STATE)
 	self:remNotify("Hilite", ui.NOTIFY_ALWAYS, NOTIFY_STATE)
-	self:remNotify("Disabled", ui.NOTIFY_ALWAYS, NOTIFY_STATE)
+	self:remNotify("Disabled", ui.NOTIFY_ALWAYS, NOTIFY_DISABLED)
 	Frame.disconnectGlobal(self)
 end
 
@@ -208,6 +209,17 @@ end
 end
 
 -------------------------------------------------------------------------------
+--	setDisabled:
+-------------------------------------------------------------------------------
+
+function Gadget:setDisabled(onoff)
+	if onoff and self.Focus then
+		self.Window:setFocusElement()
+	end
+	self:setState()
+end
+
+-------------------------------------------------------------------------------
 --	setState:
 -------------------------------------------------------------------------------
 


More information about the tekui-devel mailing list