From f24f215958b471d412b6324c9f6abe97d9736485 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Wed, 14 Jun 2023 07:36:50 -0700 Subject: [PATCH] TextArea: errorCalloutFactory --- source/feathers/controls/TextArea.as | 54 +++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/source/feathers/controls/TextArea.as b/source/feathers/controls/TextArea.as index 9a0abfd7c..c3fdc863d 100644 --- a/source/feathers/controls/TextArea.as +++ b/source/feathers/controls/TextArea.as @@ -476,6 +476,11 @@ package feathers.controls */ public static var globalStyleProvider:IStyleProvider; + private static function defaultErrorCalloutFactory():TextCallout + { + return new TextCallout(); + } + /** * Constructor. */ @@ -1338,6 +1343,52 @@ package feathers.controls this._customPromptStyleName = value; this.invalidate(INVALIDATION_FLAG_TEXT_RENDERER); } + + /** + * @private + */ + protected var _errorCalloutFactory:Function; + + /** + * A function used to instantiate the error text callout. If null, + * new TextCallout() is used instead. + * The error text callout must be an instance of + * TextCallout. This factory can be used to change + * properties on the callout when it is first created. For instance, if + * you are skinning Feathers components without a theme, you might use + * this factory to set styles on the callout. + * + *

The factory should have the following function signature:

+ *
function():TextCallout
+ * + *

In the following example, a custom error callout factory is passed + * to the text area:

+ * + * + * textArea.errorCalloutFactory = function():TextCallout + * { + * return new TextCallout(); + * }; + * + * @default null + * + * @see #errorString + * @see feathers.controls.TextCallout + */ + public function get errorCalloutFactory():Function + { + return this._errorCalloutFactory; + } + + public function set errorCalloutFactory(value:Function):void + { + if(this._errorCalloutFactory == value) + { + return; + } + this._errorCalloutFactory = value; + this.invalidate(INVALIDATION_FLAG_ERROR_CALLOUT_FACTORY); + } /** * @private @@ -1974,7 +2025,8 @@ package feathers.controls { return; } - this.callout = new TextCallout(); + var factory:Function = this._errorCalloutFactory != null ? this._errorCalloutFactory : defaultErrorCalloutFactory; + this.callout = TextCallout(factory()); var errorCalloutStyleName:String = this._customErrorCalloutStyleName != null ? this._customErrorCalloutStyleName : this.errorCalloutStyleName; this.callout.styleNameList.add(errorCalloutStyleName); this.callout.closeOnKeys = null;