app-buttons v1.3.2
#app-buttons
A library for quickly creating windows-alike applications buttons. The library can either automatically take on a dimension to fit into the program, or you can use the standard sizes which are in windows.
##How to get going quickly
First of all, require the library
var appB = require("app-buttons");
To append the app buttons to an element, simply use the following line of code:
appB.appButtons(parent, adaptive);
Here's what the two values mean:
- parent: The parent element to append the application buttons to
- adaptive: a boolean that says wether or not the library should try to adapt to the parent container or not.
You can also specify a variable when calling the library, for instance:
var appButtons = appB.appButtons(document.getElementById("app-bar"), true);
This will return you the parent container for all the application buttons.
##How to handle click events You probably want to be able to handle all click events yourself, and therefore a set of functions are called based upon what buttons are pressed. Here are the possible scenarios:
Minimize button is pressed
The function programMinimize()
is called.
Maximize button is pressed
The function programMaximize()
is called.
Close button is pressed
The function programExit()
is called.
Here's a working example:
const appB = require("app-buttons");
//Append buttons to the application bar
appB.appButtons(document.getElementById("app-bar"), true);
function programExit() {
const remote = require('electron').remote
let w = remote.getCurrentWindow()
w.close()
}
function programMaximize() {
//Do something
}
function programMinimize() {
//Do something
}
Remember: It is important to define these functions. The library won't close the program unless you write some code that tells it to do so. This is to add flexibility.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago