ComponentUtil

Published on April 30, 2022

🏷️ Tags: #extensions

A non-visible extension that provides additional tools to visible components, such as Label.

Made with Niotron IDE at https://ide.niotron.com.

Current version: 5 Package name: com.gordonlu.componentutil.aix

For more information, read this MIT App Inventor Community thread, and here for the GitHub repo.

πŸ“– Documentation

Event blocks

AfterFocus - This event is fired after the extension has attempted to give focus to a component.

Parameters: component = component, successful = boolean

GotFocus - This event is fired when a registered component is focused.

Parameters: component = component

LostFocus - This event is fired when a registered component has focus removed.

Parameters: component = component

OnClick - This event is fired when a registered component is clicked.

Parameters: component = component

OnContextMenuFinish - This event is fired when the action is completed. The isAdvanced parameter identifies whether the action is showing an advanced context menu, and the successful parameter is whether the action is successfully completed.

Parameters: isAdvanced = boolean, successful = boolean

OnKey - This event is fired when the user has pressed a hardware key while playing around with this component. To check out what keyCode means, please read the keys in https://developer.android.com/reference/android/view/KeyEvent, starting with KEYCODE_.

Parameters: component = component, keyCode = number (int)

OnLongClick - This event is fired when a registered component is long clicked.

Parameters: component = component

OnScrollChange - This event is fired when the user has scrolled the component. This probably only works with scrollable arrangements.

Parameters: component = component, prevX = number (int), prevY = number (int), currentX = number (int), currentY = number (int)

OnTouch - This event is fired when the user has touched a registered component.

Parameters: component = component

Method blocks

ApplyBlink - Applies blink animation to a component, given a specific duration and a component.

Parameters: component = component, duration = number (int), startOffset = number (int)

Bounce - Bounces the given component with the given duration and repeat counts.

Parameters: component = component, duration = number (int), repeatCount = number (int)

CanScrollDown - Checks whether the component can be scrolled vertically in a down direction. Returns: boolean

Parameters: component = component

CanScrollLeft - Checks whether the component can be scrolled horizontally in a left direction. Returns: boolean

Parameters: component = component

CanScrollRight - Checks whether the component can be scrolled horizontally in a right direction. Returns: boolean

Parameters: component = component

CanScrollUp - Checks whether the component can be scrolled vertically in a up direction. Returns: boolean

Parameters: component = component

FadeIn - Applies fade-in animation for the given component.

Parameters: component = component

FadeOut - Applies fade-out animation for the given component.

Parameters: component = component

GetBaseline - Return the offset of the component's text baseline from the widget's top boundary. If this component does not support baseline alignment, this method returns -1. Returns: number (int)

Parameters: component = component

GetBottom - Returns the bottom of this component, in pixels. Returns: number (int)

Parameters: component = component

GetContentDescription - Returns the component's content description. Returns: text

Parameters: component = component

GetElevation - Returns the base depth position, or elevation, of the component, in pixels. Returns: number (float)

Parameters: component = component

GetLeft - Returns the left edge of this component, in pixels. Returns: number (int)

Parameters: component = component

GetOpacity - Returns the opacity of the component. 0 is less opaque and 1 is most opaque. Returns: number (float)

Parameters: component = component

GetPaddingBottom - Returns the bottom padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well. Returns: number (int)

Parameters: component = component

GetPaddingEnd - Returns the end padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well. Returns: number (int)

Parameters: component = component

GetPaddingLeft - Returns the left padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well. Returns: number (int)

Parameters: component = component

GetPaddingRight - Returns the left padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well. Returns: number (int)

Parameters: component = component

GetPaddingStart - Returns the start padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well. Returns: number (int)

Parameters: component = component

GetPaddingTop - Returns the top padding of this component in pixels. If there are inset and enabled scrollbars, this value may include the space required to display the scrollbars as well. Returns: number (int)

Parameters: component = component

GetPivotX - Returns the x location of the point around which the component is rotated and scaled. Returns: number (float)

Parameters: component = component

GetPivotY - Returns the y location of the point around which the component is rotated and scaled. Returns: number (float)

Parameters: component = component

GetRight - Returns the right edge of this component, in pixels. Returns: number (int)

Parameters: component = component

GetRotation - Returns the degrees that the component is rotated around the pivot point. Returns: number (float)

Parameters: component = component

GetRotationX - Returns the degrees that the component is rotated around the horizontal axis through the pivot point. Returns: number (float)

Parameters: component = component

GetRotationY - Returns the degrees that the component is rotated around the vertical axis through the pivot point. Returns: number (float)

Parameters: component = component

GetScaleX - Returns the amount that the component is scaled in x around the pivot point, as a proportion of the view's unscaled width. Returns: number (float)

Parameters: component = component

GetScaleY - Returns the amount that the component is scaled in y around the pivot point, as a proportion of the view's unscaled width.Returns: number (float)

Parameters: component = component

GetScrollBarSize - Returns the scrollbar size for this component. Returns: number (int)

Parameters: component = component

GetScrollX - Return the scrolled left position of this component. This is the left edge of the displayed part of your component. You do not need to draw any pixels farther left, since those are outside of the frame of your component on screen. Returns: number (int)

Parameters: component = component

GetScrollY - Return the scrolled top position of this component. This is the top edge of the displayed part of your component. You do not need to draw any pixels farther top, since those are outside of the frame of your component on screen. Returns: number (int)

Parameters: component = component

GetTop - Returns the top edge of this component, in pixels. Returns: number (int)

Parameters: component = component

GetTranslationX - Returns the horizontal location of this component relative to its left position. This position is post-layout, in addition to wherever the object's layout placed it. Returns: number (float)

Parameters: component = component

GetTranslationY - Returns the vertical location of this component relative to its top position. This position is post-layout, in addition to wherever the object's layout placed it. Returns: number (float)

Parameters: component = component

GetTranslationZ - Returns the depth location of this component relative to its elevation. Returns: number (float)

Parameters: component = component

GetX - Returns the visual x position of this component, in pixels. This is equivalent to the TranslationX property plus the current left property. Returns: number (float)

Parameters: component = component

GetY - Returns the visual y position of this component, in pixels. This is equivalent to the TranslationX property plus the current top property. Returns: number (float)

Parameters: component = component

GetZ - Returns the visual z position of this component, in pixels. This is equivalent to the TranslationZ property plus the current elevation property. Returns: number (float)

Parameters: component = component

IsActivated - Indicates the activation state of this component. Activation state is not equivalent to enabling state. Returns: boolean

Parameters: component = component

IsClickable - Checks whether this component is clickable or not. Returns: boolean

Parameters: component = component

IsFocusable - Checks whether this component is currently able to take focus. Returns: boolean

Parameters: component = component

IsLongClickable - Checks whether this component is long clickable or not. Returns: boolean

Parameters: component = component

IsPressed - Checks whether this component is currently pressed by the user. Returns: boolean

Parameters: component = component

PerformClick - Performs a click for the given component.

Parameters: component = component

PerformLongClick - Performs a long click for the given component.

Parameters: component = component

RegisterClick - Registers the component so that when the user clicks the component, it will fire the OnClick event.

Parameters: component = component

RegisterFocus - Registers the component so that when the user focuses or removes focus for the component, it will fire the respective event.

Parameters: component = component

RegisterLongClick - Registers the component so that when the user clicks the component, it will fire the OnLongClick event.

Parameters: component = component

RegisterOnKey - Registers the component so that when the user presses hardware keys while playing around with this component, the extension will fire the OnKey event.

Parameters: component = component

RegisterScroll - Registers the component so that when the user scrolls the component, it will fire the OnScroll event.

Parameters: component = component

RegisterTouch - Registers the component so that when the user scrolls the component, it will fire the OnScroll event.

Parameters: component = component

RemoveContentDescription - Removes the component's content description.

Parameters: component = component

RequestFocus - Call this to try to give focus to a specific component or to one of its descendants.

Parameters: component = component

Rotate - Rotates the given component.

Parameters: component = component, degree = number (float)

ScrollTo - Scrolls the scrollable arrangement to the given position.

Parameters: scrollableArrangement = component, x = number (int), y = number (int)

SetActivated - Changes the activated state of this component.

Parameters: component = component, activate = boolean

SetBottom - Sets the bottom position of this component relative to its parent, in pixels.

Parameters: component = component, bottom = number (int)

SetContentDescription - Sets the component's content description. A content description briefly describes the component and is primarily used for accessibility support to determine how a component should be presented to the user.

Parameters: component = component, description = text

SetElevation - Sets the elevation for the given component.

Parameters: component = component, elevation = number (float)

SetFocusable - Set whether this component can receive the focus.

Parameters: component = component, focusable = boolean

SetLeft - Sets the left position of this component relative to its parent, in pixels.

Parameters: component = component, left = number (int)

SetLongClickable - Sets whether this component can be long clickable.

Parameters: component = component, longClickable = boolean

SetOpacity - Sets the opacity of this component. 0 is less opaque and 1 is most opaque.

Parameters: component = component, opacity = number (float)

SetPadding - Sets the padding of the given component.

Parameters: component = component, left = number (int), top = number (int), right = number (int), bottom = number (int)

SetPivotX - Sets the x location of the point around which the component is rotated and scaled. By default, the pivot point is centered on the object.

Parameters: component = component, pivotX = number (float)

SetPivotY - Sets the y location of the point around which the component is rotated and scaled. By default, the pivot point is centered on the object.

Parameters: component = component, pivotX = number (float)

SetRight - Sets the right position of this component relative to its parent, in pixels.

Parameters: component = component, right = number (int)

SetRipple - Applies ripple effect for the given component.

Parameters: component = component, color = color

SetRotationX - Sets the degrees that the component is rotated around the horizontal axis through the pivot point.

Parameters: component = component, rotationX = number (float)

SetRotationY - Sets the degrees that the component is rotated around the vertical axis through the pivot point.

Parameters: component = component, rotationY = number (float)

SetScaleX - Sets the amount that the component is scaled in x around the pivot point, as a proportion of the component's unscaled width. A value of 1 means that no scaling is applied.

Parameters: component = component, scaleX = number (float)

SetScaleY - Sets the amount that the component is scaled in y around the pivot point, as a proportion of the component's unscaled height. A value of 1 means that no scaling is applied.

Parameters: component = component, scaleY = number (float)

SetScrollbarFadingEnabled - Define whether scrollbars will fade when the component is not scrolling.

Parameters: component = component, fade = boolean

SetScrollbarSize - Sets the size of the scrollbar.

Parameters: component = component, size = number (int)

SetTop - Sets the top position of this component relative to its parent, in pixels.

Parameters: component = component, top = number (int)

SetTranslationX - Sets the horizontal location of this component relative to its left position.

Parameters: component = component, translationX = number (float)

SetTranslationY - Sets the vertical location of this component relative to its top position.

Parameters: component = component, translationY = number (float)

SetTranslationZ - Sets the depth location of this component relative to its elevation.

Parameters: component = component, translationZ = number (float)

SetX - Sets the visual x position of this component, in pixels. This is equivalent to setting the TranslationX property to be the difference between the x value passed in and the current left property.

Parameters: component = component, x = number (float)

SetY - Sets the visual y position of this component, in pixels. This is equivalent to setting the TranslationY property to be the difference between the y value passed in and the current top property.

Parameters: component = component, y = number (float)

SetZ - Sets the visual z position of this component, in pixels. This is equivalent to setting the TranslationZ property to be the difference between the z value passed in and the current elevation property.

Parameters: component = component, y = number (float)

ShowAdvancedContextMenu - Shows the advanced context menu for this component and fires the OnContextMenuFinish event for whether it is successful. What's different from ShowContextMenu is that you can specify the x and y position of the context menu. This function will require devices with Android versions larger or 7.0.

⚠️ NOTE: I cannot guarantee that this block works properly. That's why there is a successful parameter in the corresponding event.

Parameters: component = component, x = number (float), y = number (float)

ShowContextenu - Shows the context menu for this component and fires the OnContextMenuFinish event for whether it is successful.

⚠️ NOTE: I cannot guarantee that this block works properly. That's why there is a successful parameter in the corresponding event.

Parameters: component = component

StopAnimation - Stops all animations that you applied for the given component.

Parameters: component = component

UnregisterClick - Unregisters the component so that when it is clicked, the extension will not fire the OnClick event.

Parameters: component = component

UnregisterFocus - Unregisters the component so that when the user has focused or removed focus this component, it will not fire the respective event.

Parameters: component = component

UnregisterLongClick - Unregisters the component so that when it is clicked, the extension will not fire the OnLongClick event.

Parameters: component = component

UnregisterOnKey - Unegisters the component so that when a hardware key is pressed in this component, the extension will not fire the OnKey event.

Parameters: component = component

UnregisterScroll - Unregisters the component so that when the user has scrolled this component, it will not fire the OnScrollChange event.

Parameters: component = component

UnregisterTouch - Unregisters the component so that when the user has touched this component, it will not fire the OnTouch event.

Parameters: component = component

WillNotDraw - Checks whether the component can draw on its own. Returns: boolean

Parameters: component = component

πŸ”’ Open Source

Yes, this extension is open source! View it in Github in the official repo.

https://github.com/GordonL0049/ComponentUtil

TERMS AND CONDITIONS

By downloading or sharing my extension, you agree to follow these terms and conditions.

  1. Have fun using the extension!

  2. This, along with the MIT App Inventor original post, GitHub repo and Niotron/Android Builder community post above, are the only authorized places to download this extension. As an organization, you are not allowed to host and advertize this extension on your website, document, tweet, blog, article or any software you made without my authorization. You are also reminded not to include a direct download link of this extension on your website without my permission. If you are interested in the actions listed above, please contact me via email. Do remember that if you violate term no. 2, AICODE has the right to flag your website, document, tweet, blog or article as a violation of copyright, or other legal actions will be taken. Please contact me if you find anyone do this.

However, you can copy the link of this webpage and share it to someone as a personal identity (not as an organization), or sharing it on these authorized forums: App Inventor, Kodular, Niotron, Appzard and Android Builder communities. The term organization includes schools, markets and app stores, companies and social groups. Thank you for your understanding.

Those organizations are authorized to advertize or host my extension:

  • Kodular admins

  • MIT App Inventor admins

  • Niotron admins

  • Pura Vida Apps / Taifun Baer

  1. Selling this extension/product to anyone is not allowed unless authorized by AICODE.

  2. The extension is made Open Source. You can modify the code, but you should give credit by providing a link to this site.

  3. These terms and conditions are written and issued on December 20, 2021. AICODE has the total permission to edit these terms and conditions anytime.