Memento JavaScript UI: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Created page with "== Overview == The '''ui()''' method is a JavaScript API provided by Memento Database that grants access to a framework of methods and objects for creating user interfaces (UIs) within Memento widgets. With this method, developers can create various UI elements such as text labels, buttons, images, layers, and checkboxes. === Example Usage === <source lang="javascript"> ui().text('Hello, world!'); </source> In this example, the '''ui()''' method is called to create a n...")
 
No edit summary
Line 23: Line 23:


In this example, the layout object is created by calling the '''layout()''' method on a UI object and passing in multiple UI objects as arguments. The layout object contains a text label, a button, and an image, which are grouped together within a single view.
In this example, the layout object is created by calling the '''layout()''' method on a UI object and passing in multiple UI objects as arguments. The layout object contains a text label, a button, and an image, which are grouped together within a single view.
== Base Methods ==
Define size of an element:
'''width(width: int)''': Sets the width of the UI element in pixels.
'''height(height: int)''': Sets the height of the UI element in pixels.
'''width_match_parent()''': Sets the width of the UI element to match the parent container's width.
'''height_match_parent()''': Sets the height of the UI element to match the parent container's height.
'''width_wrap_content()''': Sets the width of the UI element to wrap the content.
'''height_wrap_content()''': Sets the height of the UI element to wrap the content.
Weight and Margin:
'''weight(weight: int)''': Sets the weight of the UI element in a layout.
'''margin(left: int, top: int, right: int, bottom: int)''': Sets the margins of the UI element in pixels.
Tag:
'''tag(text: string)''': Sets the tag for the UI element. This tag can be used to find and manipulate the element later during events such as button clicks.
Example Usage:
<source lang="javascript">
ui().button('Button').width(100).height(50).tag('button1');
</source>
In this example, a button UI element is created with a width of 100 pixels, a height of 50 pixels, and the tag "button1" is set for later reference during events such as button clicks.

Navigation menu