Texture icon indicating copy to clipboard operation
Texture copied to clipboard

ASTextNode text is overflowed whereas left padding is given

Open abbasnaqvi200 opened this issue 1 year ago • 1 comments

Why ASTextNode is overflowing instead of truncating…

HStackLayout(alignItems: .center) { img1.preferredSize(.init(width: 20, height: 20)).padding(.left, 9) img2.preferredSize(.init(width: 20, height: 20)) textNode.padding(.left, 6) } IMG_275CCDD3349C-1

abbasnaqvi200 avatar Aug 25 '23 06:08 abbasnaqvi200

You need to set style.flexShrink not equal to 0 for your padding.

Example without style.flexShrink:

Row {
    imageNode1
        .sized(CGSize(same: 20))
        .padding(.left(9))
    imageNode2
        .sized(CGSize(same: 20))
    textNode
        .padding(.horizontal(6))
}
Screenshot 2023-08-28 at 09 43 11

Example with style.flexShrink:

Row {
    imageNode1
        .sized(CGSize(same: 20))
        .padding(.left(9))
    imageNode2
        .sized(CGSize(same: 20))
    textNode
        .padding(.horizontal(6))
        .flex(shrink: 0.1)
}
Screenshot 2023-08-28 at 09 47 57

And with textNode.maximumNumberOfLines = 1: Screenshot 2023-08-28 at 09 46 47

VAndrJ avatar Aug 28 '23 06:08 VAndrJ