Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 03:49:08 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)A neat little button.
Pages: [1]
Print
Author Topic: A neat little button.  (Read 682 times)
Artsicle
Guest
« on: October 15, 2017, 01:08:40 PM »


Thats the button,
this is the code.
Code:
function createButton(info) {
var l = info.text.length;
var b = "+";
for(var m = 0; m < l+2; m++) {
b += "-";
}
b += "+";
var create = document.createElement("textarea");
create.innerHTML = b + "\n| " + info.text + " |\n" + b;
create.className += "textbutton";
create.rows = "3";
create.cols = b.length + l;
create.readOnly = true;
create.contentEditable = false;
document.body.appendChild(create);
}
And the sinple call:
Code:
	createButton({
"text":"Build",
"click": function() {
log("click");
},
"clickEvent": "mouseup"
});
The click and clickevents arent done yet, its very simple though since all I have
to do is append it to an array of buttons and then do perform a for loop when
the button is clicked in a window event and then perform the actions specified in click.
Logged
Artsicle
Guest
« Reply #1 on: October 15, 2017, 02:02:09 PM »

This is a little hard coded but it works
Code:
	createButton({
"text":"Road",
"id":"road",
"otype":"child",
"childOf":document.getElementById("park"),
"click": function() {
selectedBuilding = "Road";
},
"clickEvent": "mousedown",
"mouseOver": function() {

},
"corner":"+",
"verticalEdge": "-",
"sideEdge":"|"
});
createText({
"text":"Selected Building: ",
"update": function() {
return "Selected Building: " + selectedBuilding;
},
"otype":"child",
"childOf":document.getElementById("road")
});
And the parent before a long chain:
Code:
	createButton({
"text":"Build",
"id":"build",
"otype":"parent",
"click": function() {

},
"position": {
"x":"10",
"y":"300"
},
"clickEvent": "mousedown",
"mouseOver": function() {

},
"corner": "o",
"verticalEdge": "_",
"sideEdge":"|"
});
Logged
Samaras-Sama
Level 1
*


samy is my hero


View Profile
« Reply #2 on: October 20, 2017, 12:06:10 PM »

cool
Logged

Devlog<br /><br />[/
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic