Copy link to clipboard
Copied
I was noticing the right edge of a TextField being clipped in my GUI framework that wasn't expected.
The border of a TextField of width 10, actually occupies 11 pixels. That is incorrect. I suspect the naive programmer drew the rectangle using the drawing APIs, forgetting to take into account that although the distance from pixel 0 to 2 is 2, there are actually 3 pixels occupied [0,1,2]. Therefore, a TextField of width 10 should occupy pixel 0 through 9, and should be drawn as a rectangle of width 9, rather than 10. Drawing the rectangle of width 10 (equal to the TextField width) is wrong, because it will occupy 11 pixels.
That alone (it gets worse) results in undesired edge overlap. For example, if you have 3 TextFields, each of height 20, then you should be able to place them at y-coordinates 0, 20, and 40, and they should each occupy 20 pixels (0-19),(20-39),(40-59), with their borders butting up against each other, but not overlapping. However, this is not the case with the TextField as it currently functions, because it seems to be using the drawing APIs in such a way that it always end up occupying one additional pixel beyond its desired width and height.
The scrollRect property seems to function correctly in general, exposing the number of pixels exactly equal to the width (or height) of the rectangle, but it doesn't function correctly for IDE-generated TextFields, despite functioning correctly for TextFields created via "new TextField()". See attached picture. Is anyone aware of these nasty bugs?
I've already overridden TextField with a class that's over 600 lines long, just correcting bugs in its behavior (particular involving how it reacts to backspace and delete keys when pressed at the ends of lines, fails to update height properly, etc.), but in this case I cannot simply override the background/border behavior because TextField inherits directly from InteractiveObject, rather than Sprite, and lacks a "graphics" property that would allow me to render the border correctly. The only alternative would be for me to disable the border and background, wrap it in another container, and draw the background on the container. Thankfully, I already have a dedicated control (TextFieldWrapper), which is a customized version of my GUIControlWrapper class, which wraps non-Framework controls that don't inherit from the base GUIControl class. TextFieldWrapper primarily handles implementation of an autoHeight and autoWidth feature, which adjusts the TextField's multiline and wordWrap properties to coordinate with either an autoWidth or autoHeight mode. I just wish Adobe would update the player to draw the border the correct size and fix whatever is causing the scrollRect to become offset for TextFields created in the designer as opposed to ActionScript.
Copy link to clipboard
Copied
Confirmed.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now