Yurba Docs
Yurba Documentation

Get started

Accounts

Apps

Users

Relationships

Dialogs (Messages)

Tracks (MuseBase)

Photos

Posts

Comments

Safety

Other

Yurba CDN (cdn.yurba.one)

Yurba Desktop API

Yurba Component Language

METHOD createButton

Structure

createButton: String UniqueName, String icon? Methods structure

createButton { String name, String icon, Method setTooltip { value: String }, Method on { event: String, callback: Function }, Method setIndicator { value: Int }, Method removeIndicator, Method active, Method unactive, Method properties, } Description

Creates a button object that will be located in the upper right corner, along with all other mini-buttons. After creating the button, you can add events or add and remove information.

Example usage

This code shows how to create a regular button with an image instead of an icon and assign a tooltip that will display text on hover:

const btn = app.createButton("Weather", "img:weather.png") // Take an image from a local folder btn.setTooltip("My tooltip") // Create a tooltip with text "My tooltip"
Now let's add an indicator that works and looks like a notification. You can only put any number (int) in it, and let's say we'll remove it when the button is pressed and make it inactive:

const btn = app.createButton("Weather", "img:weather.png") // Take an image from a local folder btn.setTooltip("My tooltip") // Create a tooltip with text "My tooltip" // Event handler btn.on("click", () => { $this.removeIndicator() $this.unactive() })
The introduction states that $this is used in callbacks because the callback does not know the external context, so $this in the code becomes what we are referring to. In this case, $this is our btn.