LabelPlus - Additional methods for the Label component

Blocks:

- These blocks set and return whether the entire label is clickable (true) or not (false).


blocks - 2021-05-30T195134.770

blocks - 2021-05-30T195137.952

- This block sets the label text range as a clickable link.


hideLink - the text that will be returned to the Click event, if this text is empty, the method will return the clicked text,
clickableText - if this text is not empty, the method will find the first occurrence of this text in the label and replace it with link,
start and length - if the text attached to clickableText is empty, the method replace the text from "start" of length "length" into a link,

- This event detects clicks on the label and clicks on the clickable text. When clicking on a label, it returns component and empty text. When clicking on text, it returns the component and the clicked text.


- This event detects long clicks on the label. When long clicking on a label, it returns component.


- These blocks are used to set and return what kind of direct links to detect in the label. These links are clickable and will open in the default apps on your phone. We define the types of detected links using green blocks. We can also set the color of the links.


component_set_get (28)

component_set_get (29)

component_set_get (30)

component_set_get (31)

component_set_get (32)

blocks - 2021-05-30T205506.486

- These blocks set and return whether multiline text is to be aligned on both sides by extending a space.


blocks - 2021-05-30T203756.500

blocks - 2021-05-30T203801.268

- These blocks set and return whether the label text should be selectable. We can select the text, for example, to copy it. We can also set the color of the selection.


blocks - 2021-05-30T210310.886

blocks - 2021-05-30T210313.984

- These blocks return whether the label contains highlighted text, and the position of the beginning and end of the selection.


blocks - 2021-05-31T215241.988

- These blocks set and return the method of truncating the text to one line. The green blocks are used to select the method. The START, MIDDLE and END methods truncate the text and place 3 dots at the beginning, middle or end of the text. The MARQUEE method scrolls the text. *These methods do not work when text is selectable.*


component_set_get (23)

component_set_get (24)

component_set_get (25)

component_set_get (26)

component_set_get (6)

- These blocks manage the number of lines in the label. Set and return the count of lines.


blocks - 2021-05-30T211841.991

- These blocks set and return text alignment horizontally.


component_set_get (20)

component_set_get (21)

component_set_get (22)

- Set a shadow under text of the specified blur radius and color, and the specified distance from text position.


blocks - 2021-05-31T213400.441

- Sets a custom font for the label. You must add the font file to the app's resources.


- Sets the colors and shape of the label.


bgColorList - color list for label background gradient, if the list is single element, then the color will be uniform.
gradientOrientation - gradient orientation, four orientation properties (green blocks) are available.
borderWidth - sets the width of the label border, if you do not want the border, set the value to 0.
borderColor - sets the color of the label border, if you don't want the border, set the value to any numeric value or any color.
padding - sets the text spacing from the edges of the label. Useful for a border so that the text does not overlap the border.
radius - sets the radius of the rounded corners, if you don't want rounding set the value to 0.

component_set_get(1)

component_set_get(4)

- Sets the color gradient for the label text. This also changes the color of the links.


- Sets the height to elevate label. Creates a shadow under the label.


- Sets the text style to bold or/and italic using the green property blocks. You can also check whether the text is bold or italic.


blocks (13)

blocks (14)

component_set_get (7)

component_set_get (8)

component_set_get (9)

component_set_get (10)

- Sets the quote effect on the label by adding a vertical bar to the left of the label.


color - strip color
width - strip width (works from android9 +)
padding - width of the space between the bar and the text (works from android9 +)

blocks (16)

- Sets the blur effect on the text range.


radius - value specifies the amount of blur
blurEffect - the type of blur effect, we indicate with the green property blocks
textToBlur - if this text is not empty, the method will find the first occurrence of this text in the label and apply a blur effect to it
start and lenght - if the text attached to textToBlur is empty, specify the starting position and length of the text to which the blur effect is to be applied

component_set_get (14)

component_set_get (13)

component_set_get (12)

component_set_get (11)

- Inserts an image from the project's assets into the label. (New in v4)


image - name of the picture with the extension
height - image height
width - image width
textToReplaced - if this text is not empty, the method will find the first occurrence of this text in the label and replaces it with a picture
start and lenght - if the text attached to textToReplaced is empty, specify the starting position and length of the text that will be replaced with an image

- Sets the icon to the left of the label.


image - name of the picture with the extension
padding - width of the space between the icon and the text

blocks (19)

- Sets the font for the selected range of text in the label.


font - name of the font with the extension
textToReplaced - if this text is not empty, the method will find the first occurrence of this text in the label and replaces the font with your own font
start and lenght - if the text attached to textToReplaced is empty, specify the starting position and the length of the text, whose font will be replaced with your font

- Sets various decorations for a range of text.


typeDecoration - use the green property blocks to set the decoration type
value - the value that a given type of decoration requires
textToReplaced - if this text is not empty, the method will find the first occurrence of this text in the label and apply a decoration to it
start and lenght - if the text attached to textToReplaced is empty, specify the starting position and the length of the text, to which the decoration is to be applied

  • stretch - stretches the text horizontally, the value is a factor, and takes float numbers

component_set_get (15)

  • background color - sets the background color under the text, value takes colors

component_set_get (16)

  • color - sets the text color, value takes colors

component_set_get (17)

  • font size - sets the font size, value takes integer values

component_set_get (18)

  • strikethrough - sets text to strikethrough, set the value to any type

component_set_get (19)

  • text style - to make text bold and / or italic, set the value with the green blocks of the TextStyle property.

component_set_get (20)

  • underline - sets the text to underline, set the value to any type

component_set_get (21)

- Set the paragraph bullets. To set a bullet, a paragraph must be a new line in the text.


radius - bullet radius
color - bullet color
padding - width of the space between the bullet and the text
textToReplaced - if this text is not empty, it must be a new line, the method will find the first occurrence of this text in the label and apply a bullet to it
start and lenght - if the text attached to textToReplaced is empty, specify the starting position and the length of the text of paragraph, to which the bullet is to be applied

- Set a scrollable label, we no longer need to put a label in the VerticalScrollArrangement.


blocks (34)

- Enable label scroll detection. As we scroll through the label, the Scrolled event will be triggered.


- The event that is triggered when the label is scrolled. Returns the current highest line displayed and the height in PX.


- Methods for scrolling the label programmatically.


  • scroll the text to the specified line

blocks (37)

  • scroll the text to the specified height, expressed in PX

blocks (38)

- Methods that return height values, expressed in PX.


  • height of the displayed label

  • the height of the entire text

  • the height of the specified line

- Methods that return the text offset.


  • return the offset of the first character on a given line

  • return the offset of the last character on a given line

  • return a list of all instance offsets of the given text

- Returns the line where the given text offset occurs.


- Sets the ability to set the sharpness of the label. Appropriate events will be triggered when focus is got or lost.


blocks (50)

- Methods that programmatically request and clear focus on a label.


blocks (52)

blocks (51)

- The events that will be triggered when the focus is changed for the label.


blocks (49)

blocks (48)

- Methods to stretch text horizontally or vertically by the scale multiplier.


- Methods that shift the label horizontally or vertically by the pixel value.


blocks (57)

- The methods by which we rotate the label in any axis.


  • rotates label vertically by the specified angle

blocks (62)

  • rotates label horizontaly by the specified angle

blocks (61)

  • rotates the label along the Z axis

blocks (63)

  • Set the axis shift by the specified amount horizontally. The standard value is half the label width.

blocks (64)

  • Set the axis shift by the specified amount vertically. The standard value is half the label heigth.

blocks (65)

- A method for stretching the line spacing of a label.(New in v8) Thanks @Ken .


Extension v8:

com.extension.LabelPlus.aix (37.3 KB)

Demo project showing the possibilities:

under construction

24 Likes

Nice Extension :+1:

2 Likes

Also for constants you should use the naming conventions... for example
LinkTypeWEB_URLS should be LinkTypeWebUrls
etc

Taifun

3 Likes

During construction, at the beginning I had it. Later I changed to make the type of the constant more visible. I have a few more ideas so I will update and rename.

3 Likes

Great Extension! thanks a lot!

1 Like

Great extension !

1 Like

@Patryk_F to make the block image looks normal you have to download the image in this way.
First, do not left-click on the block, but left-click on the block editor, for example :

Screenshot (19)

@Patryk_F very good extension.
I am also thinking for similar to this I want to add spannable string support If I get time in summer I will discuss with mentor on this project.

2 Likes

I have a source of Label component with the above methods implemented. I can send you a file, you will change, you will improve, maybe some work will save.

1 Like

Yes I know about it. Here I just downloaded individual blocks from a sample project. I think it does not matter, blocks are visible and readable.

1 Like

I updated the extension.

  • new blocks added,
  • improved naming
2 Likes

Awesome Tool! :+1:

Possible to add a "long click" option so that accidentally brushing against the label does nothing?

1 Like

Thx. Yes, I can add that. I have a few more new ideas that I will also add and update the extension.

1 Like

Ultra cooooool extension !!!

1 Like

Is the modified extension available for download now?
If so, what is the URL?

1 Like

Nice extension!

1 Like

The link to the latest aix is at the bottom of the first post in this topic.

Not yet. Give me some time as I have other activities besides ai2 :blush:.

Hi @Patryk_F Great job, it works perfect :100:
Can we use the extension for textbox instead of labels. It would be so helpful if it worked for textbox as well.

My need is just that link blocks. detect links, numbers from a textbox.

2 Likes

I'm in the process of working on an extension for the textbox. I will see how this method works with textbox.

1 Like