This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
account.username's profile picture

OBB - Object Based Buttons [Simple Button API]

Started by account.username, 07 June 2014 - 02:31 AM
account.username #1
Posted 07 June 2014 - 04:31 AM
OBB

A simple and powerful button API

This is an API that I separated from my GUI API because it is powerful and useful on its own.

It consists of only 6 core functions but allows for immense customization.


Pastebin: VkAnDstn




Documentation

Spoiler

createButton( Name , Action [function] )
Creates a button with a name and trigger function.

detect( x, y, trigger? [true/false] )
​Uses x and y args from a mouse click event and checks if any buttons were clicked. It can also trigger the buttons function if you set the "trigger?" arg to true.

[button]:draw( x , y, width, color, textColor )
Draws a button at the determined coordinates with the determined colors and length and then adds it to an array of all created and draw buttons.

[button]:toggle( toggleColor, Delay )
Changes the buttons color for a determined delay. If the "delay" argument is left as nil it will toggle and stay the toggle color.

[button]:trigger()
Activates the buttons "action" which is set when the button is created.

[button]:remove()
Removes button for the button array and deletes all info tied to that but



For screen shots look at my GUI API linked in the description at the top of the post.
Edited on 07 June 2014 - 04:55 AM
skwerlman #2
Posted 07 June 2014 - 05:11 AM
Links to the code?