{"action":"created","issue":{"url":"https://api.github.com/repos/BowlerHatLLC/feathers/issues/1412","repository_url":"https://api.github.com/repos/BowlerHatLLC/feathers","labels_url":"https://api.github.com/repos/BowlerHatLLC/feathers/issues/1412/labels{/name}","comments_url":"https://api.github.com/repos/BowlerHatLLC/feathers/issues/1412/comments","events_url":"https://api.github.com/repos/BowlerHatLLC/feathers/issues/1412/events","html_url":"https://github.com/BowlerHatLLC/feathers/issues/1412","id":163465586,"number":1412,"title":"TextInput.promptFactory: BitmapFontTextRenderer.textFormat overwritten by theme.","user":{"login":"tconkling","id":709022,"avatar_url":"https://avatars.githubusercontent.com/u/709022?v=3","gravatar_id":"","url":"https://api.github.com/users/tconkling","html_url":"https://github.com/tconkling","followers_url":"https://api.github.com/users/tconkling/followers","following_url":"https://api.github.com/users/tconkling/following{/other_user}","gists_url":"https://api.github.com/users/tconkling/gists{/gist_id}","starred_url":"https://api.github.com/users/tconkling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tconkling/subscriptions","organizations_url":"https://api.github.com/users/tconkling/orgs","repos_url":"https://api.github.com/users/tconkling/repos","events_url":"https://api.github.com/users/tconkling/events{/privacy}","received_events_url":"https://api.github.com/users/tconkling/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-01T20:05:40Z","updated_at":"2016-07-01T20:24:32Z","closed_at":"2016-07-01T20:24:32Z","body":"I'm having an issue with `TextInput.promptFactory` where my prompt's text format is being overwritten after creation. \r\n\r\nI'm creating a TextInput and assigning it a promptFactory:\r\n\r\n```actionscript\r\n    public static function createInputText (prompt :String, isPassword :Boolean, parent :Sprite) :TextInput {\r\n        var textInput :TextInput = new TextInput();\r\n\r\n        // add the TextInput to the sprite before changing its properties, or they'll be overridden\r\n        // by feathers\r\n        parent.addChild(textInput);\r\n\r\n        textInput.promptFactory = function () :ITextRenderer {\r\n            var tr :BitmapFontTextRenderer = new BitmapFontTextRenderer();\r\n            tr.textFormat = new BitmapFontTextFormat(FONT_UI_LARGE, 10, 0x666666);\r\n            return tr;\r\n        };\r\n        textInput.promptProperties = null;\r\n        textInput.prompt = prompt;\r\n        textInput.width = 150;\r\n        textInput.height = 22;\r\n        textInput.displayAsPassword = isPassword;\r\n        textInput.textEditorProperties.fontFamily = \"Helvetica\";\r\n        textInput.textEditorProperties.fontSize = 12;\r\n        textInput.textEditorProperties.color = 0x0;\r\n\r\n        return textInput;\r\n    }\r\n```\r\n\r\nMy promptFactory creates a `BitmapFontTextRenderer`, assigns it a `textFormat`, and returns it. However, when the `BitmapFontTextRenderer` is later added to the stage by its TextInput parent, the theme I'm using (`BaseMinimalMobileTheme`) overwrites that textFormat in the `BaseMinimalMobileTheme.setTextInputPromptStyles` function.\r\n\r\nIs this the intended behavior? (This was not happening when I was using Feathers 2.) What's the proper way to get that textFormat to stick?"},"comment":{"url":"https://api.github.com/repos/BowlerHatLLC/feathers/issues/comments/230039588","html_url":"https://github.com/BowlerHatLLC/feathers/issues/1412#issuecomment-230039588","issue_url":"https://api.github.com/repos/BowlerHatLLC/feathers/issues/1412","id":230039588,"user":{"login":"joshtynjala","id":141885,"avatar_url":"https://avatars.githubusercontent.com/u/141885?v=3","gravatar_id":"","url":"https://api.github.com/users/joshtynjala","html_url":"https://github.com/joshtynjala","followers_url":"https://api.github.com/users/joshtynjala/followers","following_url":"https://api.github.com/users/joshtynjala/following{/other_user}","gists_url":"https://api.github.com/users/joshtynjala/gists{/gist_id}","starred_url":"https://api.github.com/users/joshtynjala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshtynjala/subscriptions","organizations_url":"https://api.github.com/users/joshtynjala/orgs","repos_url":"https://api.github.com/users/joshtynjala/repos","events_url":"https://api.github.com/users/joshtynjala/events{/privacy}","received_events_url":"https://api.github.com/users/joshtynjala/received_events","type":"User","site_admin":false},"created_at":"2016-07-01T20:24:32Z","updated_at":"2016-07-01T20:24:32Z","body":"This is the intended behavior, and it also behaved this way in Feathers 2. However, the theme may have done some things differently that could explain why you're seeing different behavior. The old theme probably used textInput.promptProperties before, and it no longer does (because I now consider those properties objects a poor design decision, and I avoid them completely). You set input.promptProperties to null, but the theme doesn't use that object anymore.\r\n\r\nYou have two options (and these are the recommended practice for styling any sub-component):\r\n\r\n1. Set the text renderer's style provider to null in the promptFactory. This will tell it not to use the theme at all. You can immediately set properties and be sure that the theme won't replace them:\r\n\r\n    ``` as3\r\n    var tr :BitmapFontTextRenderer = new BitmapFontTextRenderer();\r\n    tr.styleProvider = null;\r\n    tr.textFormat = new BitmapFontTextFormat(FONT_UI_LARGE, 10, 0x666666);\r\n    ```\r\n    This works especially well for text renderers because you usually want to fully replace their default font styles. For more complex components where you want to keep some of the theme's defaults, the second option usually works better.\r\n1. You can use an AddOnFunctionStyleProvider to ensure that custom styles don't get set until after the theme has set its defaults:\r\n\r\n    ``` as3\r\n    var tr :BitmapFontTextRenderer = new BitmapFontTextRenderer();\r\n    tr.styleProvider = new AddOnFunctionStyleProvider(tr.styleProvider, function(tr:BitmapFontTextRenderer):void\r\n    {\r\n        tr.textFormat = new BitmapFontTextFormat(FONT_UI_LARGE, 10, 0x666666);\r\n    };\r\n    ```\r\n\r\nThe function that you pass to AddOnFunctionStyleProvider is called after the theme's code, so it's similar to your old trick of adding the component to the stage before changing styles."}}
{"actor":{"display_login":"joshtynjala"}}