Skip to content

Commit

Permalink
TextArea: errorCalloutFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Jun 14, 2023
1 parent bef091a commit f24f215
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion source/feathers/controls/TextArea.as
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ package feathers.controls
*/
public static var globalStyleProvider:IStyleProvider;

private static function defaultErrorCalloutFactory():TextCallout
{
return new TextCallout();
}

/**
* Constructor.
*/
Expand Down Expand Up @@ -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,
* <code>new TextCallout()</code> is used instead.
* The error text callout must be an instance of
* <code>TextCallout</code>. 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.
*
* <p>The factory should have the following function signature:</p>
* <pre>function():TextCallout</pre>
*
* <p>In the following example, a custom error callout factory is passed
* to the text area:</p>
*
* <listing version="3.0">
* textArea.errorCalloutFactory = function():TextCallout
* {
* return new TextCallout();
* };</listing>
*
* @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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f24f215

Please sign in to comment.